Please note that I am using Department and Employee tables from HR.
Objective: After this small exercise, we would have created a department page, where we can select a department and navigate to the employee page to find employees of the corresponding department.
Let’s start with creating view objects (for Departments and Employees). No, we are not using master-details relationship here, just two view objects.
Let’s follow these steps now!
- Create jsf(Containing a table of departments)
- jsf(Containing a table of employees)
- Let’s set the navigation between the two pages.
- Let’s create a managed bean and a method for the Navigation button’s action.
- We will use the below set of code lines for the action’s method in managed bean.
Here, the idea is to get the current row of the DepartmentsVO, which is derived from the iterator.
–Find the binding for the current page definition(Department page) : DCBindingContainer bindings= (DCBindingContainer)BindingContext.
getCurrent().getCurrentBindingsEntry();
–Find the Iterator from the binding :
DCIteratorBinding dcIteratorBinding = bindings.findIteratorBinding(“DepartmentsView1Iterator”);
–Find the Departments View Object from the Iterator : ViewObject deptVO = dcIteratorBinding.getViewObject();
–Store the departmentId of the current row in a Managed Bean variable :
this.setDeptIdParam((deptVO.getCurrentRow().
getAttribute(“DepartmentId”).toString()));
–Find the iterator for the Employees :
DCIteratorBinding dcIteratorBinding1 = bindings.findIteratorBinding(“EmployeesView1Iterator”);
–Find the Employees View Object from the Iterator :
ViewObject empVO = dcIteratorBinding1.getViewObject();
–Filter the Employees View Object based on the DepartmentId and navigate to the Employees page :
empVO.setWhereClause(null);
String wc = “1 = 1”;
if(this.getDeptIdParam()!=null)
{
wc = wc+” AND DEPARTMENT_ID = “+this.getDeptIdParam();
}
System.out.println(“empVO wc”+wc);
empVO.setWhereClause(wc);
empVO.executeQuery();
System.out.println(“empVO found”);
return “FindEmps”;
ليست هناك تعليقات:
إرسال تعليق