ADF Basics: Filter ViewObject data using getFilteredRows and RowQualifier

Sharing is Caring
Sometimes we need to get filtered data from ViewObject using one or multiple conditions,
Though this is the very basic of framework yet new developers find it confusing.

There are two ways of filtering ViewObject

 1. In this we apply WHERE clause on ViewObject and it affects resultSet data, Suppose we have Department ViewObject and we want to see data of DepartmentId 4 on page after filtering, for this viewCritera, bind variables comes in action
ADF Basics: Apply and Change WHERE Clause of ViewObject at runtime programmatically

2. In this user want to get filtered data (Rows) in code only without any effect on ViewObject resultSet (page data), Here I am discussing this point

We can get filtered data from view object using two methods-

Using getFilteredRows method

To filter viewObject data using one condition (equals to attribute), We can use getFilteredRows method like this

//Get ViewObject Instance
ViewObject deptVo = this.getDepartments1();
//Filter data using getFilteredRows method
Row filteredRows[] = deptVo.getFilteredRows("ManagerId", 103);

//Get Values from returned rowset
for (Row r : filteredRows) {
System.out.println("Filtered Row- " + r.getAttribute("DepartmentName") + "n");
}

and output is

Using RowQualifier

RowQualifier is used to filter view object using multiple conditions, We can pass SQL WHERE clause in RowQualifier object.
It filters ViewObject data using that WHERE condition and returns an array of Row

        //Get ViewObject Instance
ViewObjectImpl deptVo = this.getDepartments1();
//Filter data using RowQualifier
RowQualifier rq=new RowQualifier(deptVo);
//Write condition in SQL query format
rq.setWhereClause("DepartmentId=150 and ManagerId=103");
Row filteredRows[] = deptVo.getFilteredRows(rq);

//Get Values from returned rowset
for (Row r : filteredRows) {
System.out.println("Filtered Row- " + r.getAttribute("DepartmentName") + "n");
}

and output is

Cheers 🙂 Happy Learning

Related Posts

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

0 thoughts on “ADF Basics: Filter ViewObject data using getFilteredRows and RowQualifier”

Leave a Reply

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