8 Replies Latest reply on Mar 27, 2009 8:40 AM by Christian Yttesen

    rich:datatable filterExpression f:setPropertyActionListener

    Christian Yttesen Newbie

      Hi,

      I'm using a rich:datatable with a filterExpression on one of my columns. My problem is that after using the filter (e.g narrowing the number of rows in my table) - clicking the command link will populate the wrong row - seems like it will use the row from the "unfiltered" result.

      Any ideas/suggestions to get around this - or am I doing something wrong?

      <rich:column filterExpression="#{fn:containsIgnoreCase(item.accessUsername, filterBean['accessUsername'])}">
       <f:facet name="header">
       <h:panelGrid columns="1" styleClass="full">
       <h:outputText value="#{msgs['operator_activity.column6_account']}" />
       <h:inputText id="filterAccount" value="#{filterBean['accessUsername']}">
       <a4j:support event="onchange" reRender="tblOperatorActivities" focus="filterAccount" />
       </h:inputText>
       </h:panelGrid>
       </f:facet>
       <h:commandLink action="#{operatorActivityPageBean.showAccount}" immediate="true">
       <f:setPropertyActionListener value="#{item}" target="#{operatorActivityPageBean.selectedOperatorActivityLog}" />
       <h:outputText value="#{item.accessUsername}" />
       </h:commandLink>
      </rich:column>
      


      Thanks,
      Christian

        • 3. Re: rich:datatable filterExpression f:setPropertyActionListe
          Ilya Shaikovsky Master

          could you please check this using actionparam instead of f:set*.. Such issue was fixed even before 3.3.0 Ga.

          • 4. Re: rich:datatable filterExpression f:setPropertyActionListe
            Christian Yttesen Newbie

            Using the a4j:actionparam like:

            <a4j:actionparam name="account" value="#{item.accountID}" assignTo="#operatorActivityPageBean.accountId}" />
            


            works fine - however it seems like the value attribute ends up as a String - I receive an IllegalArgumentException: argument type mismatch if using it "like" the f:setPropertyActionListener (e.g value="#{item}") - I read the JavaDoc for the value attribute to evaluate to a java.lang.Object?:

            javax.el.ELException: /operatorActivity.jsp @131,79 assignTo="#{operatorActivityPageBean.selectedOperatorActivityLog}":
            Can't set property 'selectedOperatorActivityLog' on class 'dsl.gui.bean.OperatorActivityPageBean' to value '<jli>, 2009-03-04 19:35:34.0, Modified value for css_rac_cat_id [New value: 1,000,380], Subscription Log, administrator, Parameter value changed, 1112000'.
            



            • 5. Re: rich:datatable filterExpression f:setPropertyActionListe
              Christian Yttesen Newbie

              Please disregard my understanding of the value attribute - I was clearly wrong (referring to the developers guide instead of just the tag information doc).

              • 6. Re: rich:datatable filterExpression f:setPropertyActionListe
                Christian Yttesen Newbie

                Ilya,

                Any change you have been able to investigate further on this issue?

                Regards,
                Christian

                • 7. Re: rich:datatable filterExpression f:setPropertyActionListe
                  Ilya Shaikovsky Master

                  my changed code from demosite

                  <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                   xmlns:ui="http://java.sun.com/jsf/facelets"
                   xmlns:h="http://java.sun.com/jsf/html"
                   xmlns:f="http://java.sun.com/jsf/core"
                   xmlns:a4j="http://richfaces.org/a4j"
                   xmlns:rich="http://richfaces.org/rich">
                  
                   <h:form>
                   <a4j:region>
                   <rich:dataTable value="#{dataTableScrollerBean.allCars}"
                   var="category" rows="20" rowKeyVar="row"
                   ajaxKeys="#{dataTableScrollerBean.keys}" id="table">
                   <f:facet name="header">
                   <h:outputText value="Cars Store"/>
                   </f:facet>
                   <rich:column filterBy="#{category.make}">
                   <f:facet name="header">
                   <h:outputText value="Make" />
                   </f:facet>
                   <h:outputText value="#{category.make}" id="make" />
                   </rich:column>
                   <rich:column>
                   <f:facet name="header">
                   <h:outputText value="Model" />
                   </f:facet>
                   <h:outputText value="#{category.model}" id="model" />
                   </rich:column>
                   <rich:column>
                   <f:facet name="header">
                   <h:outputText value="Price" />
                   </f:facet>
                   <h:outputText value="#{category.price}" id="price" />
                   </rich:column>
                   <rich:column>
                   <f:facet name="header">
                   <h:outputText value="Mileage" />
                   </f:facet>
                   <h:outputText value="#{category.mileage}" />
                   </rich:column>
                   <rich:column width="200px">
                   <f:facet name="header">
                   <h:outputText value="VIN" />
                   </f:facet>
                   <h:outputText value="#{category.vin}" />
                   </rich:column>
                   <rich:column>
                   <f:facet name="header">
                   <h:outputText value="Stock" />
                   </f:facet>
                   <h:outputText value="#{category.stock}" />
                   </rich:column>
                   <rich:column>
                   <f:facet name="header">
                   Actions
                   </f:facet>
                   <a4j:commandLink ajaxSingle="true" id="editlink"
                   oncomplete="#{rich:component('editPanel')}.show()">
                   <h:graphicImage value="/images/icons/edit.gif" style="border:0"/>
                   <f:setPropertyActionListener value="#{category}"
                   target="#{dataTableScrollerBean.currentItem}" />
                   <f:setPropertyActionListener value="#{row}"
                   target="#{dataTableScrollerBean.currentRow}" />
                   </a4j:commandLink>
                   <rich:toolTip for="editlink" value="Edit"/>
                   <a4j:commandLink ajaxSingle="true" id="deletelink"
                   oncomplete="#{rich:component('deletePanel')}.show()">
                   <h:graphicImage value="/images/icons/delete.gif" style="border:0"/>
                   <f:setPropertyActionListener value="#{row}"
                   target="#{dataTableScrollerBean.currentRow}" />
                   </a4j:commandLink>
                   <rich:toolTip for="deletelink" value="Delete"/>
                   </rich:column>
                   <f:facet name="footer">
                   <rich:datascroller renderIfSinglePage="false" maxPages="5"/>
                   </f:facet>
                   </rich:dataTable>
                   </a4j:region>
                   </h:form>
                  
                   <rich:modalPanel id="editPanel" autosized="true" width="450">
                   <f:facet name="header">
                   <h:outputText value="Edit Current Car" />
                   </f:facet>
                   <f:facet name="controls">
                   <h:panelGroup>
                   <h:graphicImage value="/images/modal/close.png"
                   id="hidelink" styleClass="hidelink"/>
                   <rich:componentControl for="editPanel" attachTo="hidelink"
                   operation="hide" event="onclick" />
                   </h:panelGroup>
                   </f:facet>
                   <h:form>
                   <rich:messages style="color:red;"></rich:messages>
                   <h:panelGrid columns="1">
                   <a4j:outputPanel ajaxRendered="true">
                   <h:panelGrid columns="2">
                   <h:outputText value="Make"/>
                   <h:inputText value="#{dataTableScrollerBean.currentItem.make}" />
                   <h:outputText value="Model" />
                   <h:inputText value="#{dataTableScrollerBean.currentItem.model}" />
                   <h:outputText value="Price" />
                   <h:inputText value="#{dataTableScrollerBean.currentItem.price}" label="Price"/>
                   </h:panelGrid>
                   <rich:message showSummary="true" showDetail="false" for="price"/>
                   </a4j:outputPanel>
                   <a4j:commandButton value="Store"
                   action="#{dataTableScrollerBean.store}"
                   reRender="make, model, price"
                   oncomplete="if (#{facesContext.maximumSeverity==null}) #{rich:component('editPanel')}.hide();" />
                   </h:panelGrid>
                   </h:form>
                   </rich:modalPanel>
                   <rich:modalPanel id="deletePanel" autosized="true" width="200">
                   <f:facet name="header">
                   <h:outputText value="Delete this car from list?"
                   style="padding-right:15px;" />
                   </f:facet>
                   <f:facet name="controls">
                   <h:panelGroup>
                   <h:graphicImage value="/images/modal/close.png"
                   styleClass="hidelink" id="hidelink2" />
                   <rich:componentControl for="deletePanel" attachTo="hidelink2"
                   operation="hide" event="onclick" />
                   </h:panelGroup>
                   </f:facet>
                   <h:form>
                   <table width="100%">
                   <tbody>
                   <tr>
                   <td align="center" width="50%">
                   <a4j:commandButton value="Yes" ajaxSingle="true"
                   action="#{dataTableScrollerBean.delete}"
                   oncomplete="#{rich:component('deletePanel')}.hide();"
                   reRender="table" />
                   </td>
                   <td align="center" width="50%">
                   <a4j:commandButton value="Cancel"
                   onclick="#{rich:component('deletePanel')}.hide();return false;" />
                   </td>
                   </tr>
                   </tbody>
                   </table>
                   </h:form>
                   </rich:modalPanel>
                   <a4j:status onstart="#{rich:component('wait')}.show()" onstop="#{rich:component('wait')}.hide()"/>
                   <rich:modalPanel id="wait" autosized="true" width="200" height="120" moveable="false" resizeable="false">
                   <f:facet name="header">
                   <h:outputText value="Processing"/>
                   </f:facet>
                   <h:outputText value="Wait Please..."/>
                   </rich:modalPanel>
                   <rich:messages></rich:messages>
                  </ui:composition>
                  
                  


                  works fine after filtering. I'm using edit button and new values shown in modal panel.

                  • 8. Re: rich:datatable filterExpression f:setPropertyActionListe
                    Christian Yttesen Newbie

                    Lesson learned - don't store your "filtering" value in a request-scoped bean.

                    My filtering bean was stored in request scope. This explains the observed behavior. I was facing a similar unwanted behavoir - using filtering and navigation using the datascroller - it was "clearing" my filter - thus all elements would reappear when using the datascroller.

                    Thanks Ilya for taking the time to confirm it was not a RF bug - I'm still learning.