9 Replies Latest reply on Feb 26, 2009 6:01 PM by Nick Belaevski

    Filtering datatable and getRowData

    Thomas Delhoménie Newbie

      Hello,

      I'm using filters on my datatable and when the datatable is filtered, the getRowData() method on my UIDataTable object does not give me the right row.
      I have seen at https://jira.jboss.org/jira/browse/RF-3067 that I need to use a ModifiableModel.
      Can someone give me an example please ?

        • 1. Re: Filtering datatable and getRowData
          Nick Belaevski Master

          Hello,

          What RF version do you use?

          • 3. Re: Filtering datatable and getRowData
            Konstantin Mishin Novice

            Hello toomtooms.
            Description of your problem is very short. Post your page and bean code, please.

            • 4. Re: Filtering datatable and getRowData
              Thomas Delhoménie Newbie

              Sorry.
              Here is my page :

              <h:form id="frmTable">
               <rich:dataTable
               binding="#{ManageUsers.table}"
               onRowMouseOver="this.style.backgroundColor='#C8DC01'"
               onRowMouseOut="this.style.backgroundColor='#{org.richfaces.SKIN.tableBackgroundColor}'"
               onRowClick="this.style.backgroundColor='#F1F1F1'"
               width="100%" id="tbl" value="#{ManageUsers.users}" var="u">
               <f:facet name="header">
               <rich:columnGroup>
               <rich:column>
               <h:outputText value="Nom" />
               </rich:column>
               <rich:column>
               <h:outputText value="Prénom" />
               </rich:column>
               <rich:column>
               <h:outputText value="Modifier" />
               </rich:column>
               <rich:column>
               <h:outputText value="Supprimer" />
               </rich:column>
               </rich:columnGroup>
               </rich:columnGroup>
               </f:facet>
               <rich:column id="nom" styleClass="columnNom"
               filterMethod="#{ManageUsers.filterNom}">
               <f:facet name="header">
               <h:inputText id="filterNomInput" value="#{ManageUsers.filterNomValue}"
               styleClass="filterNom">
               <a4j:support event="onkeyup" ignoreDupResponses="true"
               requestDelay="700" reRender="tbl"
               oncomplete="setCaretToEnd(event);">
               </a4j:support>
               </h:inputText>
               </f:facet>
               <h:outputText value="#{u.nom}" />
               </rich:column>
               <rich:column id="prenom" styleClass="columnPrenom"
               filterMethod="#{ManageUsers.filterPrenom}">
               <f:facet name="header">
               <h:inputText id="filterPrenomInput" value="#{ManageUsers.filterPrenomValue}"
               styleClass="filterPrenom">
               <a4j:support event="onkeyup" ignoreDupResponses="true"
               requestDelay="700" reRender="tbl"
               oncomplete="setCaretToEnd(event);">
               </a4j:support>
               </h:inputText>
               </f:facet>
               <h:outputText value="#{u.prenom}" />
               </rich:column>
               <rich:column styleClass="columnModifier">
               <a4j:commandLink id="editLink" reRender="panelFormUser" actionListener="#{ManageUsers.editAction}"
               oncomplete="#{rich:component('panelFormUser')}.show()">
               <h:graphicImage style="border:0" url="images/edit.gif" />
               </a4j:commandLink>
               </rich:column>
               <rich:column styleClass="columnSupprimer">
               <h:graphicImage style="border:0;cursor:pointer;" url="images/delete.gif"
               onclick="#{rich:component('panelConfirmDelete')}.show()" />
               <rich:modalPanel id="panelConfirmDelete" width="250" height="115"
               resizeable="false">
               <f:facet name="header">
               <h:outputText value="Confirmation"></h:outputText>
               </f:facet>
               <div style="text-align: center;font-size:10pt;">
               <h:outputText value="Etes-vous sûr de vouloir supprimer ce covoitureur ?"></h:outputText>
               <br />
               <br />
               <a4j:commandButton value=" OK "
               actionListener="#{ManageUsers.deleteAction}"
               reRender="tbl,panelFormUser"></a4j:commandButton>
               <a4j:commandButton value="Annuler" onclick="#{rich:component('panelConfirmDelete')}.hide()"></a4j:commandButton>
               </div>
               </rich:modalPanel>
               </rich:column>
               </rich:dataTable>
               </h:form>
              
              


              and my action :
              public void editAction(ActionEvent e) {
               User user = (User) table.getRowData();
               ...
               }


              For example, if I click on the first row of my filtered table, I get data of the first row of the original table.
              Is it clear ? Do you need more information ?

              • 5. Re: Filtering datatable and getRowData
                Konstantin Mishin Novice

                What scope bean "ManageUsers" has?

                • 6. Re: Filtering datatable and getRowData
                  Thomas Delhoménie Newbie

                  request

                  but I tried with to put it in session and it works !
                  Thank you

                  • 7. Re: Filtering datatable and getRowData
                    Konstantin Mishin Novice

                    It's good.
                    But I recommend not to use binding a component as a property of a class with session scope.

                    • 9. Re: Filtering datatable and getRowData
                      Nick Belaevski Master

                      No. It's not recommended to store components in session scope because this may produce unwanted effects (multi threading quirks, incorrect state etc. issues)