Pre-Requirements: Table Employee and Department in HR schema
Use-case: List of values of all departments and when selection changes all employees in this department will display.
Steps:
- Add method 'public void GetEmployeesInDepartment(Integer departmentId)' to AMImpl
- Add departmentId to bind variable in EmployeeVO in where condition or in view criteria then execute the query.
- Expose the method to client interface.
- Drop DepartmentVO from Data Control into your page then select 'Single Selection' and choice display attribute
- In behavior tab in property inspector:
- Add ValueChanged Listener to a bean method (say xBean).
- In page binding tab:
- Add new 'attributeValues' binding (Select DepartmentVO for iterator and DepartmentId for attribute) to get selected department id.
- Add new 'methodAction' binding(select 'GetEmployeeInDepartment" from AM and set parameter '#{bindings.DepartmentId.inputValue}.
- Drop EmployeeVO from Data Control into your page as form.
- In valueChange Listner method in xBean, Add the following code:
this.setValueToEL("#{bindings.DepartmentVO.inputValue}", valueChangeEvent.getNewValue()); //Updates the model and binding layer with new selected department
BindingContainer bc = BindingContext.getCurrent().getCurrentBindingsEntry();
OperationBinding oper = bc.getOperationBinding("GetEmployeeInDepartment");
oper.execute();
No comments:
Post a Comment