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.


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.

Comments

  1. 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?

    ReplyDelete
  2. try using criteriaItems facet for af:quickQuery

    ReplyDelete
  3. Jobinesh,

    This is with reference to your Blog http://www.jobinesh.com/2011/03/using-component-for-filtering-child.html


    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

    SELECT Employees.EMPLOYEE_ID,
    Employees.FIRST_NAME,
    Employees.LAST_NAME,
    Employees.EMAIL,
    Employees.PHONE_NUMBER,
    Employees.HIRE_DATE,
    Employees.JOB_ID,
    Employees.SALARY,
    Employees.COMMISSION_PCT,
    Employees.MANAGER_ID,
    Employees.DEPARTMENT_ID
    FROM EMPLOYEES Employees
    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.



    Regards
    Vidya

    ReplyDelete

Post a Comment