Search This Blog

ADF - Programatically Applying and Creating View Criteria

CASE 1: I have already created a view criteria in EmployeeVO, and I want to call it programmatically.
 
public void searchEmployee(Number employeeId) {
        ViewObjectImpl vo = getEmployeesView1();
        ViewCriteria vc = vo.getViewCriteria("findEmployeeVC");
        vo.applyViewCriteria(vc);
        vo.setNamedWhereClauseParam("pEmployeeId", employeeId);
        vo.executeQuery();
    }


CASE 2: I want to create a view criteria dynamically and execute it programmatically.


    public void searchByEmployeeIdEmail(Number employeeId, String email) {
        ViewObjectImpl vo = getEmployeesView2();
        ViewCriteria vc = vo.createViewCriteria();
        ViewCriteriaRow vcRow = vc.createViewCriteriaRow();
        
        vcRow.setAttribute("EmployeeId", employeeId);
        vc.addRow(vcRow);
        vcRow.setAttribute("Email", email);
        vc.addRow(vcRow);
        
        vo.applyViewCriteria(vc);
        vo.executeQuery();
 
 CASE 3: Apply ExecuteQuery() in View Layer 
 
DCBindingContainer bindings2 = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
JUCtrlHierBinding obj = (JUCtrlHierBinding)bindings2.findCtrlBinding("EmployeesEOView1");
ViewObject vo= obj.getViewObject();
vo.setNamedWhereClauseParam("BindEmployeeId",101);
vo.executeQuery(); 
  
Code to check the value in query : 
 
DCBindingContainer dcBindings =(DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
DCIteratorBinding dciter = dcBindings.findIteratorBinding(
EmployeesEOView1Itterator
);
RowSetIterator RowSetI = dciter.getRowSetIterator();
for (Row row : RowSetI.getAllRowsInRange()) {
System.out.println("Row : " + row);
}
RowSetI.closeRowSetIterator();
 
 
 

No comments:

Post a Comment