20 October 2013

Putting LOV in ADF Table Filter

Create two View Object "EmployeeVO" and "DepartmentLOV" and shuttle both your VO in application module as shown in figure below.



Now create a jspx and then create a read only or editable table by taking EmployeesVO based on your requirement.

Now create a SelectOneChoice inside the DepartmentId column as follows:

<af:column sortProperty="DepartmentId" filterable="true"
                     sortable="true"
                     headerText="#{bindings.EmployeesVO1.hints.DepartmentId.label}"
                     id="c2" width="140">
            <af:selectOneChoice value="#{row.bindings.DepartmentId.inputValue}"
                                label="#{row.bindings.DepartmentId.label}"
                                required="#{bindings.EmployeesVO1.hints.DepartmentId.mandatory}"
                                shortDesc="#{bindings.EmployeesVO1.hints.DepartmentId.tooltip}"
                                id="soc1" readOnly="true">
              <f:selectItems value="#{row.bindings.DepartmentId.items}"
                             id="si1"/>
            </af:selectOneChoice>
          </af:column>

if your table is read only put readonly="true" for  <af:selectOneChoice>.

Now go to binding tab of jspx or jsff page and create a iterator for DepartmentLOV as shown below.


You will get the following screen:

Kindly select the VO by expanding AppModule as shown in figure below and click on OK.


Now go to bindings section and click on add and select "Tree" from list as shown in image below.


Now select the iterator then add the rule as shown below:


Once the rule will be added shuttle all your attribute right side as shown below:

Now go to Department table column and add the following line of code inside the column:

<f:facet name="filter">
      <af:selectOneChoice label="Label 3" id="soc55"
                                      value="#{vs.filterCriteria.DepartmentId}"
                                      autoSubmit="true">
             <f:selectItem itemValue="" itemLabel="" id="si55"/>
                    <af:forEach var="listrow"
                                       items="#{bindings.DepartmentLOV1.rangeSet}">
                             <f:selectItem id="si56" itemValue="#{listrow.DepartmentId}"
                                                 itemLabel="#{listrow.DepartmentName}"/>
                    </af:forEach>
       </af:selectOneChoice>
</f:facet>

Now the whole DepartmentId column code will look similar to this.


 <af:column sortProperty="DepartmentId" filterable="true"
                     sortable="true"
                     headerText="#{bindings.EmployeesVO1.hints.DepartmentId.label}"
                     id="c2" width="140">
            <af:selectOneChoice value="#{row.bindings.DepartmentId.inputValue}"
                                label="#{row.bindings.DepartmentId.label}"
                                required="#{bindings.EmployeesVO1.hints.DepartmentId.mandatory}"
                                shortDesc="#{bindings.EmployeesVO1.hints.DepartmentId.tooltip}"
                                id="soc1" readOnly="true">
              <f:selectItems value="#{row.bindings.DepartmentId.items}"
                             id="si1"/>
            </af:selectOneChoice>
            <f:facet name="filter">
              <af:selectOneChoice label="Label 3" id="soc55"
                                  value="#{vs.filterCriteria.DepartmentId}"
                                  autoSubmit="true">
                <f:selectItem itemValue="" itemLabel="" id="si55"/>
                <af:forEach var="listrow"
                            items="#{bindings.DepartmentLOV1.rangeSet}">
                  <f:selectItem id="si56" itemValue="#{listrow.DepartmentId}"
                                itemLabel="#{listrow.DepartmentName}"/>
                </af:forEach>
              </af:selectOneChoice>
            </f:facet>
    </af:column>

when you will run your page you can see the LOV in table filter as shown below:


Now when you will select some value in LOV you can see the filtered result as shown below:


That's all :) Happy Coding.



0 on: "Putting LOV in ADF Table Filter"