In previous example, i demonstrated how to use parametrized query to populate the the adf table. Here i will achieve the same using operation binding
1. Create 2 view objects:
a. DepartmentVO : select * from departments
b. EmployeeDeptVO : select * from employee where department_Id-:dept where dept is a bind variable. Make sure to create its impl class
3. create following custom method in AppmodImpl:
public void getEmployeeForDept(String deptId){
ViewObjectImpl vo = (ApplicationRoleVOImpl)findViewObject("EmployeeDeptVO1");
vo.setNamedWhereClauseParam("dept", deptId);
vo.executeQuery();
}
and add this method in the page def of the jspx
public void getEmployeeForDept(String deptId){
ViewObjectImpl vo = (ApplicationRoleVOImpl)findViewObject("EmployeeDeptVO1");
vo.setNamedWhereClauseParam("dept", deptId);
vo.executeQuery();
}
and add this method in the page def of the jspx
4. On jspx, drag and drop the departnmentvo as selectone choice component
make sure to use department name as display attribute
5. drag and drop the EmployeeDeptVO as adf table on page
6. create attribute binding on the page def for departmentId(using this we can get the value selected in dropdown)
7. write following line in vcl of the drop down
BindingContext bctx = BindingContext.getCurrent();
BindingContainer bindings = bctx.getCurrentBindingsEntry();
FacesContext contxt = FacesContext.getCurrentInstance();
valueChangeEvent.getComponent().processUpdates(contxt);
AttributeBinding applicationNameBinding = (AttributeBinding)bindings.getControlBinding("DepartmentId");
String DepartmentId= applicationNameBinding.getInputValue().toString();
DepartmentId = applicationNameBinding.getInputValue().toString();
System.out.println("DepartmentId Selected " + DepartmentId);
oracle.adf.model.OperationBinding op = (oracle.adf.model.OperationBinding)getBindings().get("getEmployeeForDept");
op.getParamsMap().put("deptId", DepartmentId);
Object result = op.execute();
AdfFacesContext.getCurrentInstance().addPartialTarget(getEmployeeTable());
8. Once the application is run the table is populated based on the department selected in the department drop down
BindingContainer bindings = bctx.getCurrentBindingsEntry();
FacesContext contxt = FacesContext.getCurrentInstance();
valueChangeEvent.getComponent().processUpdates(contxt);
AttributeBinding applicationNameBinding = (AttributeBinding)bindings.getControlBinding("DepartmentId");
String DepartmentId= applicationNameBinding.getInputValue().toString();
DepartmentId = applicationNameBinding.getInputValue().toString();
System.out.println("DepartmentId Selected " + DepartmentId);
oracle.adf.model.OperationBinding op = (oracle.adf.model.OperationBinding)getBindings().get("getEmployeeForDept");
op.getParamsMap().put("deptId", DepartmentId);
Object result = op.execute();
AdfFacesContext.getCurrentInstance().addPartialTarget(getEmployeeTable());
8. Once the application is run the table is populated based on the department selected in the department drop down
No comments:
Post a Comment