This procedure describes how to implement the managed bean of the application Web development component app_web. For example, it stores logic such as methods for finding and storing entity instances, also methods for navigating between the available JSPs, and so on.
Open for editing the ProjectMB under app_web/Java_Resources:resource/com.sap.nwce.ra.edm.managedbean.
Using EJB 3.0 annotation, inject the Project Facade EJB.
Syntax
@EJB private ProjectFacadeLocal projectFacade;
Add the following properties (including setters and getters)
Search patterns:
Syntax
private String projectsPtrn = ""; private String employeesPtrn = "";
Currently selected entities:
Syntax
private Project currentProject = new Project(); private Employee currentEmployee = new Employee();
Add the following property (getter method only) for project employees.
Syntax
private HashMap<Integer, Employee> tempCurrProjEmplMap = new HashMap<Integer, Employee>(); public List<Employee> getTempCurrProjEmployees() { return new ArrayList<Employee>(tempCurrProjEmplMap.values()); }
Add methods for finding and storing Project and Employee entity instances, and methods for navigating between the JSPs. Here is an example of such a method:
Syntax
public String navigationNewEmployee() { currentEmployee = new Employee(); return "newEmployee"; }
Add methods for navigation to editProject and editEmployee. These methods have to read as a parameter current ID. Here is an example:
Syntax
private String obtainJSFParam(String param) { String emplId = null; FacesContext context = FacesContext.getCurrentInstance(); Map<String, String[]> paramsMap = context.getExternalContext() .getRequestParameterValuesMap(); if (paramsMap.containsKey(param)) { emplId = paramsMap.get(param)[0]; } return emplId; } public String editEmloyee() { String param = "emplId"; String emplId = obtainJSFParam(param); currentEmployee = projectFacade.getEmployeeById(Integer.parseInt(emplId)); return "editEmployee"; }
Enter the full source code of the ProjectMB.