2 Replies Latest reply on Apr 17, 2009 11:44 AM by icampista

    Dynamic Filtering of Dynamic Columns based on external dynam

    icampista

      Hi there,

      "pushing the filtering expression to the limits"

      I'm trying to make a dynamic filtering on dynamic columns (forEach), and additionally, selecting which column is the one to filter (external combo selects the column).

      The filtering is using the filterExpression attribute.

      The data model is a matrix, so the filterExpression expression needs to know somehow know which value to evaluate according to the column (i.e. and index would help).


      I have been trying hard to get those together, but something is just not working, any help is appreciated. The examples for filterExpression is too much of trivial, so they are not helping.

      filterBean.filterValue is a string from an input field. i.e. "John"

      usersDataTable.selectedColumnIndex is an index integer from a combo box. i.e. 0

      Somehow the filter expression does not behave correctly. BUT if I remove the forEach, and replace the counter.index with two columns and a proper number for two iterations, the filtering works.

      I run out of ideas....



      Here is my table

      <rich:dataTable value="#{usersDataTable.model}" var="row"
      id="table" rows="10">
      <c:forEach var="column" items="#{usersDataTable.columns}"
      varStatus="counter">
      <rich:column
      filterExpression="${(row[counter.index].idx != usersDataTable.selectedColumnIndex) || (fn:containsIgnoreCase(row[counter.index].value, filterBean.filterValue)) }">
      <f:facet name="header">
      <h:outputText value="#{column.header}" />
      </f:facet>
      <h:outputText value="#{row[counter.index].value}" />
      </rich:column>
      </c:forEach>
      </rich:dataTable>

        • 1. Re: Dynamic Filtering of Dynamic Columns based on external d
          konstantin.mishin

          We suggest to you to try to use # instead of $ in filterExpression.

          • 2. Re: Dynamic Filtering of Dynamic Columns based on external d
            icampista

            I have tried that, but did not work. Thanks anyway.


            I have found an alternative solution. The curious thing is that the fn:containsIgnoreCase breaks the EL expression. Somehow it never gets resolved. The JSTL EL of the facelets is not working.

            The workaround is that I created a map wrapper with an equivalent function. At the end I got:

            <rich:dataTable value="#{usersDataTable.model}" var="row"
            id="table" rows="10">
            <rich:columns var="col" value="#{usersDataTable.columns}" index="ind"
            filterExpression="${(ind != usersDataTable.selectedColumnIndex) || ((usersDataTable.filterValue != null) and (usersDataTable.filterValue != '') and (usersDataTable.containsIgnoreCase(row[ind].value) eq 'true')) }">
            <f:facet name="header">
            <h:outputText value="#{column.header}" />
            </f:facet>
            <h:outputText value="#{row[ind].value}" />
            </rich:column>
            </c:forEach>
            </rich:dataTable>
            


            The function usersDataTable.containsIgnoreCase is alreday aware of the filterValue, so there is no need to pass a 2nd parameter, which is anyway impossible as map wrapper (overwritting the Map.get(Object key) function).


            Now the question is WHY the JSTL function is not working. I have even defined a custom facelets taglib function and as well is not working. Really strange.