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.
Download
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.
3 comments:
Awesome ! Thanks a lot.
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?
try using criteriaItems facet for af:quickQuery
Post a Comment