selectOneChoice table filter for LOV column

August 8th, 2010 | Posted by in Oracle ADF | 3 Comments

In this post I am going to show how to add a selectOneChoice component as a filter for a column with LOV.

When displaying data into tables and using the out-of-the-box filtering feature, you might want for a column with list of values attribute to also have that list of values in the filter section.

The demo application is built on hr schema and considered we have already built the Model project with business components for Employees and Departments, and the EmployeesVO has a LOV on DepartmentId attribute.

In the ViewController project we then create a new jspx page, employees.jspx and add the employees table from DataControl -> EmployeesVO with Filtering option checked.

To add the data model behind the selectOneChoice filter we intend to put into the department column, we select the Bindings tab for employees page and add a new binding in the Bindings box. Select ‘tree’ in the next window of the create binding wizzard and then fill in the data as in the following screenshot:

In the Source tab of employee page, we add the filter facet for the department column (lines 5-14):

          <af:column sortProperty="DepartmentId" filterable="true"
                     sortable="false"
                     headerText="#{bindings.EmployeesVO.hints.DepartmentId.label}"
                     id="c4" width="150">
            <f:facet name="filter">
              <af:selectOneChoice value="#{vs.filterCriteria.DepartmentId}"
                                  label="Dep" unselectedLabel="" id="soc2">
                <af:forEach items="#{bindings.DepartmentsVO.rangeSet}"
                            var="item">
                  <f:selectItem id="si2" itemLabel="#{item.DepartmentName}"
                                itemValue="#{item.DepartmentId}"/>
                </af:forEach>
              </af:selectOneChoice>
            </f:facet>
            <af:selectOneChoice value="#{row.bindings.DepartmentId.inputValue}"
                                label="#{row.bindings.DepartmentId.label}"
                                required="#{bindings.EmployeesVO.hints.DepartmentId.mandatory}"
                                shortDesc="#{bindings.EmployeesVO.hints.DepartmentId.tooltip}"
                                id="soc1">
              <f:selectItems value="#{row.bindings.DepartmentId.items}"
                             id="si1"/>
            </af:selectOneChoice>
          </af:column>

The sample application can be downloaded from here: LOVFilter.

Tags: , , ,

3 Responses to “selectOneChoice table filter for LOV column”

  1. Siddi says:

    Can we Apply customized filter?
    I mean when we select ‘Marketing’ value from dropdown,It should display list of employees of ‘Marketing’ Department

    If so how to apply customized filter in this case?

  2. Kanika Dhamija says:

    Hi,

    I have implemented the same thing in my af:table
    My question is that after having column in the adf table.
    How can i get the selected value for a particular row in backing bean.

    Thanks in Advance

    • Anca says:

      Hi Kanika,

      You should use the view accessor for the LOV used in that column, and get the row at the new selection in the selectOneChoice component. If you use valueChangeListener, you can get the new index from valueChangeEvent.getNewValue().

Leave a Reply