ADF Model: Programmatically executing view criteria in AMImpl method

public void getEmployeesInDept(Integer deptId) {
    if (deptId == null || deptId == 0) {
        ViewObjectImpl empDeptVO = this.getEmpDeptVO();
        //View Criteria without bind variable
        ViewCriteria vc = empDeptVO.getViewCriteria("noRowsVC");
        empDeptVO.applyViewCriteria(vc);
        empDeptVO.executeQuery();
    } else {
        ViewObjectImpl empDeptVO = this.getEmpDeptVO();
        //View Criteria with bind variable 'Bind_deptId'
        empDeptVO.setApplyViewCriteriaName("findByDeptId");
        empDeptVO.setNamedWhereClauseParam("Bind_deptId", deptId);
        empDeptVO.executeQuery();
    }
}

The above method shows how to execute view criterias “noRowsVC”(with no bind variables) and “findByDeptId”(which has a bind variable “Bind_deptId”) in EmpDeptVO. The below screenshots show the view criterias in EmpDeptVO.

That’s it. The method executes the VC and gets the query results. You can expose this method in client’s interface and add this method in jsff pagedef file as a methodAction binding. The later post shows how to pass parameters and call/execute this AMImpl method ( i.e., getEmployeesInDept) in UI project’s java bean.

Programmatically executing view criteria in AMImpl method



Programmatically executing view criteria in AMImpl method





http://www.adftips.com/2010/10/adf-model-programmatically-executing.html