3 Replies Latest reply on Mar 10, 2009 10:14 AM by Keith Kile

    filterBy not working with facelets ui:param (but sortBy does

    Keith Kile Newbie

      I'm using the following code to wrap a rich:column insides a facelets 'page tag' in order to save myself some typing:

      tableColumn.xhtml:

      <ui:composition>
       <rich:column id="#{id}"
       filterBy="#{value}"
       sortBy="#{value}"
       ...>
       <f:facet><h:outputText value="#{label}"></f:facet>
       <h:outputText value="#{value}"/>
      </ui:composition>
      

      where id, value and label are all passed in for each column (m:tableColumn) as follows:

      main.xhtml:
      <ui:composition>
       <rich:extendedDataTable value="#{someDataModel}" var="record">
      
       <m:tableColumn id="namecol" value="#{record.name}" label="some localized label"/>
      
       <m:tableColumn id="streetcol" value="#{record.street}" label="some other localized label"/>
      
       </rich:extendedDataTable>
      </ui:composition>
      


      This seems like a pretty logical way of using facelets to create a page component that wraps rich:column, and it initially appears to work because the table appears, the columns seem to contain the right data in each cell. The sorting even seems to work just fine--even in multi-column sort mode.

      However, when I enter in filter text for either column, the table seems to be filtering ONLY on the last tableColumn defined in the main.xhtml (in this case, street). No matter how many tableColumn instances I create, the filtering always occurs on the content of the last column.

      Example:

      the rows are rendered as such:
      Name | Street
      [ ] | [ ]
      ___________________________
      Bill | First Street
      Jane | Second Street
      


      If for the name filter I type in "Bill", no rows are displayed (as though there are no matches for the filter).
      If for the name filter I type in "First", then the first row is displayed

      If I leave the name column clear, and entered "First" for the street filter, then the first row is displayed. If I entered "Second", then only the second row is displayed.

      So in conclusion, it looks like the last column is being used to sort the first column. Something about how facelets is making the EL expression results available to the filterby method is not working. The same expression used for the sortBy seems to work just fine.

      Any ideas would be greatly appreciated!

      - Keith K.


        • 1. Re: filterBy not working with facelets ui:param (but sortBy
          Keith Kile Newbie

          After some experimentation, I also reproduced the problem with the following xml:

          <rich:extendedDataTable value="#{someDataModel}" var="record">
          
           <ui:param name="x" value="#{record.name}"/>
           <rich:column id="namecol"
           filterBy="#{x}"
           sortBy="#{x}"
           ...>
           ...
           </rich:column>
          
          
           <ui:param name="x" value="#{record.street}"/>
           <rich:column id="streetcol"
           filterBy="#{x}"
           sortBy="#{x}"
           ...>
           ...
           </rich:column>
          
          </rich:extendedDataTable>
          


          My intuition tells me that I dont yet fully understand the way EL expressions are evaluated at the time when facelets is building the component tree and the time the rich extendedDataTable is being rendered. The fact that sortBy seems to be working fine and filterBy seem conflicting to me, which is why I think this is more of a RichFaces problem than a facelets issue. Maybe somebody with some inside knowledge about sortBy and filterBy can point out why they work differently in this case...

          Thanks again.

          Keith K.

          • 2. Re: filterBy not working with facelets ui:param (but sortBy
            ashutosh deora Newbie

            in the following data table sortBy is not working can u tell me what is the error
            i am using richfaces 3.3.0



            <rich:dataTable value="#{listData}" var="list" border="2" rendered="true" >
            <rich:column sortBy="#{list.trainName}" sortOrder="ASCENDING" sortable="true" selfSorted="true">
            <f:facet name="header">
            <h:outputText value="carame" />
            </f:facet>
            <h:outputText value="#{list.trainName}" />
            </rich:column>
            <rich:column sortBy="#{list.sourceName}" sortable="true" selfSorted="true">
            <f:facet name="header">
            <h:outputText value="Source Name" />
            </f:facet>
            <h:outputText value="#{list.sourceName}" />
            </rich:column>
            <rich:column sortBy="#{list.destinationName}" sortable="true" selfSorted="true">
            <f:facet name="header">
            <h:outputText value="Destination Name" />
            </f:facet>
            <h:outputText value="#{list.destinationName}" />
            </rich:column>
            </rich:dataTable>

            • 3. Re: filterBy not working with facelets ui:param (but sortBy
              Keith Kile Newbie

               

              "ashutoshdeora" wrote:
              in the following data table sortBy is not working can u tell me what is the error
              i am using richfaces 3.3.0



              <rich:dataTable value="#{listData}" var="list" border="2" rendered="true" >
              <rich:column sortBy="#{list.trainName}" sortOrder="ASCENDING" sortable="true" selfSorted="true">
              <f:facet name="header">
              <h:outputText value="carame" />
              </f:facet>
              <h:outputText value="#{list.trainName}" />
              </rich:column>
              <rich:column sortBy="#{list.sourceName}" sortable="true" selfSorted="true">
              <f:facet name="header">
              <h:outputText value="Source Name" />
              </f:facet>
              <h:outputText value="#{list.sourceName}" />
              </rich:column>
              <rich:column sortBy="#{list.destinationName}" sortable="true" selfSorted="true">
              <f:facet name="header">
              <h:outputText value="Destination Name" />
              </f:facet>
              <h:outputText value="#{list.destinationName}" />
              </rich:column>
              </rich:dataTable>


              I am currently using sortBy without using any of the sortable, sortOrder and selfSorted attributes. Try removing all but sortBy to see if it works then add the others in incrementally until it stops working.

              I don't think this has anything to do with my original question though and should probably be moved over to its own posting.

              Keith