Creating and Executing View Criteria Programmatically

Sharing is Caring

Sometimes you need dynamic ViewCriteria that you can handle at runtime, ADF provides Java classes for handling View Objects, View Criteria and other business components.
Here is the solution for creating and executing View Criteria Programmatically.

Sample UseCase-

    • Suppose you have Department VO
    • You want to filter this VO for DepartmentId 10
    • You can do this using this code snippet
/**Get ViewObject*/
ViewObject vo = getAm().getDepartments1();
/**Create ViewCriteria on ViewObject*/
ViewCriteria vc = vo.createViewCriteria();
/**Create ViewCriteriaRow for that Criteria*/
ViewCriteriaRow vcRow = vc.createViewCriteriaRow();
/**Set the values for ViewCriteriaRow*/
vcRow.setAttribute(“DepartmentId”, 10);
/**Add row to ViewCriteria*/
vc.addRow(vcRow);
/**Apply Criteria on ViewObject*/
vo.applyViewCriteria(vc);
/**Execute ViewObject*/
vo.executeQuery();
public pcAMImpl getAm() {
pcAMImpl am = (pcAMImpl)resolvElDC(“pcAMDataControl”);
return am;
}

Cheers 🙂 Happy Learning

Related Posts

I’m an Oracle ACE, Blogger, Reviewer,
Technical Lead working on Oracle ADF

0 thoughts on “Creating and Executing View Criteria Programmatically”

Leave a Reply

Your email address will not be published. Required fields are marked *