/** * Go to detail page * * @return forward to DETAIL page */ public String detail() { Integer id = Integer.parseInt(FacesUtils.getRequestParameter("id")); idea = manager.getEntityById(id); return SpringUtils.isAclPermissionGranted(idea, BasePermission.WRITE) ? NavigationResults.EDIT : NavigationResults.DETAIL; }
/** * Save bean and stay on it * * @return forward to list page */ public String save() { doBeforeSave(); if (idea.getId() == null) { manager.insertEntity(idea); } else { manager.updateEntity(idea); } // Calls an after save action String result = doAfterSave(NavigationResults.LIST); // Unselect object // idea = null; return null; }
/** * List ideas. Order depends on Faces parameter sort. * * @return the list of all ideas sorted by requested criterion */ public List<Idea> getAll() { return manager.getAllEntities(search, new SortCriteria(sortColumn, sortAscending)); }
/** * UI bean for Idea objects. * * @author stajanov code generator */ public class IdeaBean extends BaseBean { /** Serial version field */ private static final long serialVersionUID = -1L; private static AuthenticationManager authMgr = AuthenticationManager.getDefault(); /* idea - generated by stajanov (do not edit/delete) */ /** Logger */ private static final Log log = LogFactory.getLog(IdeaBean.class); /** Active search object */ private IdeaSearch search = new IdeaSearch(); /** Manager */ private static IdeaManager manager = IdeaManager.getDefault(); /** Upload service */ private static final Uploader uploader = UploaderFactory.getInstance("idea"); /** Active Idea object */ private Idea idea; /** Default sort column */ private String sortColumn = "name"; /** Default sort order */ private boolean sortAscending = true; /** Quick search letter for ABC pager control */ private Character letter; /** * List ideas. Order depends on Faces parameter sort. * * @return the list of all ideas sorted by requested criterion */ public List<Idea> getAll() { return manager.getAllEntities(search, new SortCriteria(sortColumn, sortAscending)); } // Getters to list possible values of related entities /** * Get the list of all users * * @return the list of all users */ public List<SelectItem> getUsers() { List<User> refs = UserManager.getDefault().getAllEntities(null, new SortCriteria("name")); ArrayList<SelectItem> ret = new ArrayList<SelectItem>(); for (User ref : refs) { ret.add(new SelectItem(ref, ref.getName())); } return ret; } // Getters to list possible values of enum fields // Methods to create/remove instances of one-to-many entities (slave entities) /** * Whether or not create button is available for user * * @return true if user can create objects of type Idea */ public boolean isCreateAvailable() { return SpringUtils.isRolePermissionGranted(Permission.Entity_Create(Idea.class)); } /** * Whether or not edit button is available for user * * @return true if user can edit current object */ public boolean isEditAvailable() { return SpringUtils.isAclPermissionGranted(idea, BasePermission.WRITE); } /** * Whether or not delete button is available for user * * @return true if user can delete current object */ public boolean isDeleteAvailable() { return (idea.getId() != null) && SpringUtils.isAclPermissionGranted(idea, BasePermission.DELETE); } /** * Go to create page * * @return forward to CREATE page */ public String create() { idea = new Idea(); idea.setCreationDate(new Date()); idea.setUser(authMgr.getCurrentPrincipal().getUser()); return NavigationResults.CREATE; } /** * Go to detail page * * @return forward to DETAIL page */ public String detail() { Integer id = Integer.parseInt(FacesUtils.getRequestParameter("id")); idea = manager.getEntityById(id); return SpringUtils.isAclPermissionGranted(idea, BasePermission.WRITE) ? NavigationResults.EDIT : NavigationResults.DETAIL; } /** * Save bean and stay on it * * @return forward to list page */ public String save() { doBeforeSave(); if (idea.getId() == null) { manager.insertEntity(idea); } else { manager.updateEntity(idea); } // Calls an after save action String result = doAfterSave(NavigationResults.LIST); // Unselect object // idea = null; return null; } /** * Delete bean and go back to beans list * * @return forward to LIST page */ public String delete() { manager.deleteEntity(idea); idea = null; return NavigationResults.LIST; } /** * Go back to beans list * * @return forward to LIST page */ public String list() { return NavigationResults.LIST; } /** * Reset search criteria * * @return forward to LIST page */ public String reset() { search.reset(); return list(); } /** * Go to search page * * @return forward to SEARCH page */ public String search() { return NavigationResults.SEARCH; } /** * Check if we have an active object. * * @return true is an object is selected */ public boolean isIdeaSelected() { return idea != null; } // Getters and setters to manipulate sorting public boolean isSortAscending() { return sortAscending; } public void setSortAscending(boolean sortAscending) { this.sortAscending = sortAscending; } public String getSortColumn() { return sortColumn; } public void setSortColumn(String sortColumn) { this.sortColumn = sortColumn; } // Getters and setters to handle search public IdeaSearch getSearch() { return search; } public Date getSearchStartCreationDate() { return search.getStartCreationDate(); } public void setSearchStartCreationDate(Date val) { if (val != null) { search.setStartCreationDate(val); } else { search.unsetStartCreationDate(); } } public boolean isSearchStartCreationDateValid() { return search.isStartCreationDateSet(); } public void setSearchStartCreationDateValid(boolean val) { if (val) { search.setStartCreationDate(search.getStartCreationDate()); } else { search.unsetStartCreationDate(); } } public Date getSearchEndCreationDate() { return search.getEndCreationDate(); } public void setSearchEndCreationDate(Date val) { if (val != null) { search.setEndCreationDate(val); } else { search.unsetEndCreationDate(); } } public boolean isSearchEndCreationDateValid() { return search.isEndCreationDateSet(); } public void setSearchEndCreationDateValid(boolean val) { if (val) { search.setEndCreationDate(search.getEndCreationDate()); } else { search.unsetEndCreationDate(); } } public String getSearchName() { return search.getName(); } public void setSearchName(String val) { if (search.isNameSet()) { search.setName(val); } } public boolean isSearchNameValid() { return search.isNameSet(); } public void setSearchNameValid(boolean val) { if (val) { search.setName(search.getName()); } else { search.unsetName(); } } public String getSearchDescription() { return search.getDescription(); } public void setSearchDescription(String val) { if (search.isDescriptionSet()) { search.setDescription(val); } } public boolean isSearchDescriptionValid() { return search.isDescriptionSet(); } public void setSearchDescriptionValid(boolean val) { if (val) { search.setDescription(search.getDescription()); } else { search.unsetDescription(); } } public String getSearchBenefits() { return search.getBenefits(); } public void setSearchBenefits(String val) { if (search.isBenefitsSet()) { search.setBenefits(val); } } public boolean isSearchBenefitsValid() { return search.isBenefitsSet(); } public void setSearchBenefitsValid(boolean val) { if (val) { search.setBenefits(search.getBenefits()); } else { search.unsetBenefits(); } } public String getSearchCost() { return search.getCost(); } public void setSearchCost(String val) { if (search.isCostSet()) { search.setCost(val); } } public boolean isSearchCostValid() { return search.isCostSet(); } public void setSearchCostValid(boolean val) { if (val) { search.setCost(search.getCost()); } else { search.unsetCost(); } } public Integer getSearchDepartmentId() { return search.getDepartmentId(); } public void setSearchDepartmentId(Integer val) { if (search.isDepartmentIdSet()) { search.setDepartmentId(val); } } public boolean isSearchDepartmentIdValid() { return search.isDepartmentIdSet(); } public void setSearchDepartmentIdValid(boolean val) { if (val) { search.setDepartmentId(search.getDepartmentId()); } else { search.unsetDepartmentId(); } } public Date getSearchStartInsertDate() { return search.getStartInsertDate(); } public void setSearchStartInsertDate(Date val) { if (val != null) { search.setStartInsertDate(val); } else { search.unsetStartInsertDate(); } } public boolean isSearchStartInsertDateValid() { return search.isStartInsertDateSet(); } public void setSearchStartInsertDateValid(boolean val) { if (val) { search.setStartInsertDate(search.getStartInsertDate()); } else { search.unsetStartInsertDate(); } } public Date getSearchEndInsertDate() { return search.getEndInsertDate(); } public void setSearchEndInsertDate(Date val) { if (val != null) { search.setEndInsertDate(val); } else { search.unsetEndInsertDate(); } } public boolean isSearchEndInsertDateValid() { return search.isEndInsertDateSet(); } public void setSearchEndInsertDateValid(boolean val) { if (val) { search.setEndInsertDate(search.getEndInsertDate()); } else { search.unsetEndInsertDate(); } } public Date getSearchStartUpdateDate() { return search.getStartUpdateDate(); } public void setSearchStartUpdateDate(Date val) { if (val != null) { search.setStartUpdateDate(val); } else { search.unsetStartUpdateDate(); } } public boolean isSearchStartUpdateDateValid() { return search.isStartUpdateDateSet(); } public void setSearchStartUpdateDateValid(boolean val) { if (val) { search.setStartUpdateDate(search.getStartUpdateDate()); } else { search.unsetStartUpdateDate(); } } public Date getSearchEndUpdateDate() { return search.getEndUpdateDate(); } public void setSearchEndUpdateDate(Date val) { if (val != null) { search.setEndUpdateDate(val); } else { search.unsetEndUpdateDate(); } } public boolean isSearchEndUpdateDateValid() { return search.isEndUpdateDateSet(); } public void setSearchEndUpdateDateValid(boolean val) { if (val) { search.setEndUpdateDate(search.getEndUpdateDate()); } else { search.unsetEndUpdateDate(); } } public User getSearchUser() { return search.getUser(); } public void setSearchUser(User val) { if (search.isUserSet()) { search.setUser(val); } } public boolean isSearchUserValid() { return search.isUserSet(); } public void setSearchUserValid(boolean val) { if (val) { search.setUser(search.getUser()); } else { search.unsetUser(); } } /** Handle an ABC pager letter click: filter objects by specified starting letter */ public void letterClicked() { if (letter != null) { UIComponent comp = FacesUtils.getComponent("ideas:list"); HtmlDataTable tabla = (HtmlDataTable) comp; tabla.setFirst(0); search.setName(letter + "%"); } else { search.unsetName(); } } public Character getLetter() { return letter; } public void setLetter(Character letter) { this.letter = letter; } // Getters and setters to handle uploads // Getters and setters to manipulate active Idea object public java.lang.Integer getId() { return idea.getId(); } public Date getCreationDate() { return idea.getCreationDate(); } public void setCreationDate(Date creationDate) { idea.setCreationDate(creationDate); } public String getName() { return idea.getName(); } public void setName(String name) { idea.setName(name); } public String getDescription() { return idea.getDescription(); } public void setDescription(String description) { idea.setDescription(description); } public String getBenefits() { return idea.getBenefits(); } public void setBenefits(String benefits) { idea.setBenefits(benefits); } public String getCost() { return idea.getCost(); } public void setCost(String cost) { idea.setCost(cost); } public Integer getDepartmentId() { return idea.getDepartmentId(); } public void setDepartmentId(Integer departmentId) { idea.setDepartmentId(departmentId); } public Date getInsertDate() { return idea.getInsertDate(); } public void setInsertDate(Date insertDate) { idea.setInsertDate(insertDate); } public Date getUpdateDate() { return idea.getUpdateDate(); } public void setUpdateDate(Date updateDate) { idea.setUpdateDate(updateDate); } public User getUser() { return idea.getUser(); } public void setUser(User user) { idea.setUser(user); } /* idea - generated by stajanov (do not edit/delete) */ }
/** * Delete bean and go back to beans list * * @return forward to LIST page */ public String delete() { manager.deleteEntity(idea); idea = null; return NavigationResults.LIST; }