Skip to main content

Using <af:quickQuery> component for filtering child nodes of a tree

In todays post I'm sharing some tips to intercept the query execution of <af:quickQuery> to generate custom queries for filtering child nodes of a tree component. I do have a screen as shown in the following screen shot. The left pane of panelSplitter displays tree table with Department-Employee hierarchy. The <af:quickQuery> (displayed on top) is built by dragging and dropping the 'All Queriable Attributes' of the Employee View Object instance. The same Employee View Object instance is displayed on right side of the panelSplitter.


You can download the sample workspace from here.
[Runs with Oracle JDeveloper 11g R1 PS3 + HR Schema]

A glance at the implementation

This sample uses a custom queryListener method for the <af:quickQuery> to intercept the search action. This custom method executes the associated default search binding. Apart from this part, the method is also responsible for adding the hooks for filtering the child nodes -Employees records displayed below the Department (parent) node in the tree table. To filter the child nodes based on the search criteria from <af:quickQuery>, queryListener method gets the ViewCriteria from the QueryEvent and pass the same to Department View Object. Please take a look at the source of TestBean::processQuery(...) to get a more detailed picture of the implementation. The filtering of child nodes/rows of the tree table is achieved at the ViewObject level by overriding the ViewObjectImpl::createViewLinkAccessorRS(AssociationDefImpl assocDef, ViewObjectImpl accessorVO, Row masterRow, java.lang.Object[] values). This method will get executed when you click on the parent node(built from this View Object) to see the child nodes.

This sample has one more interesting feature. If you select a Employee row displayed below Department node in the tree table, you may notice that employee details displayed on right pane changes to diaplay the selected child row detail. This is achieved by using TargetIterator property of the nodeDefinition binding. This part is well explained in Fusion Developers Guide - 24.5.4 Using the TargetIterator Property

PS: Another sample using ViewCriteria (instead of static query with bind variable as in the above sample) to filter child nodes of the tree is uploaded here. Rest of the implementation remains same as we discussed before.


Luis Correa said…
Awesome ! Thanks a lot.
swath said…
Hi Jibonesh,

This post is really helpful.. but I need to turn off one feature on QuickQuery .. I do not want to have drop down in the Query component. Could you please provide me some inputs on this?
Jobinesh said…
try using criteriaItems facet for af:quickQuery
Anonymous said…

This is with reference to your Blog

I have a requirement where i need to display Email along with first name and last in the search drop down of Quick Query

To achieve that

I added another bind variable called bndVarEmail and altered the query of Employees View

WHERE (Employees.FIRST_NAME = :bndVarFirstName OR :bndVarFirstName IS NULL) AND (Employees.LAST_NAME = :bndVarLastName OR :bndVarLastName IS NULL)
AND (Employees.EMAIL = :bndVarEmail OR :bndVarEmail IS NULL)

but still my email is not appearing in the drop down of search.

How to add multiples values in Search DropDown of Quick Query ?

Thanks in advance.


Popular posts from this blog

How to set Bind Variable Values at runtime ?

In this post I'm sharing a couple of approaches for programmatically setting bind variables values at run time. This post is an attempt to explain 'When to use what ?'[ In case if you are familiar with 'Bind Variables' in ADF BC, please refer Section 5.10, Working with Bind Variables in Fusion Developer's Guide ]

1. Set the Bind Variable value using RowSet::setNamedWhereClauseParam(...)

You can use use the setNamedWhereClauseParam(...) method on the ViewObject interface (which extends oracle.jbo.RowSet) to set the value for bind variables. Please note this sets the value on default RowSet. In other words, this doesn't have any effect on the secondary RowSets that you/system generates.
ViewObject vo = am.findViewObject("EmployeesView1"); vo.setNamedWhereClauseParam("bindVarDeptId", new Number(10)); vo.executeQuery();
2. Set the Bind Variable value using ViewObject's VariableValueManager::setVariableValue(...)

VariableValueManager Ma…