public void saveSelected() { if (getCurrent().getId() != null && getCurrent().getId() > 0) { getFacade().edit(current); UtilityController.addSuccessMessage("savedOldSuccessfully"); } else { current.setCreatedAt(Calendar.getInstance(TimeZone.getTimeZone("IST")).getTime()); current.setCreater(getSessionController().getLoggedUser()); getFacade().create(current); UtilityController.addSuccessMessage("savedNewSuccessfully"); } recreateModel(); getItems(); }
/** Delete the current PackageItem */ public void delete() { if (current != null) { current.setRetired(true); current.setRetiredAt(Calendar.getInstance(TimeZone.getTimeZone("IST")).getTime()); current.setRetirer(getSessionController().getLoggedUser()); getFacade().edit(current); UtilityController.addSuccessMessage("DeleteSuccessfull"); } else { UtilityController.addSuccessMessage("NothingToDelete"); } recreateModel(); getItems(); current = null; getCurrent(); }
/** * @param facesContext * @param component * @param object * @return */ @Override public String getAsString(FacesContext facesContext, UIComponent component, Object object) { if (object == null) { return null; } if (object instanceof PackageItem) { PackageItem o = (PackageItem) object; return getStringKey(o.getId()); } else { throw new IllegalArgumentException( "object " + object + " is of type " + object.getClass().getName() + "; expected type: " + PackageItemController.class.getName()); } }
public void addToPackage() { if (getCurrentPackege() == null) { UtilityController.addErrorMessage("Please select a package"); return; } if (getCurrentItem() == null) { UtilityController.addErrorMessage("Please select an item"); return; } PackageItem pi = new PackageItem(); pi.setPackege(getCurrentPackege()); pi.setItem(getCurrentItem()); pi.setCreatedAt(Calendar.getInstance(TimeZone.getTimeZone("IST")).getTime()); pi.setCreater(sessionController.loggedUser); getFacade().create(pi); UtilityController.addSuccessMessage("Added"); recreateModel(); }