4 Replies Latest reply on Sep 2, 2009 2:25 PM by nbelaevski

    RichFaces DataTable and the mystery of the out of synch row

    nmatrix9

      Hello RichFaces,

      I'm stuck on a slight richfaces datatable issue, You see I have datatable with a list of usernames and I also have a inputText field where upon entering a name the datatable rerenders with closest username results. Upon which I can drag and drop the user name on drop target BUT for some reason after the datatable is rerendered and I try to drag and drop the search result username, after dropping the username it's still pointing to the old "row Index? and data".

      for example I do a search for "John_1" and the datatable rerenders with search result "John_1". So now when I drag that username (John_1) and drop it on the drop target the drop target is suppose to display "John_1" but instead it displays the previous first row username before search (lets call that username "username_Index0").

      My assumption as to what is going on is that even though the datatable is being re-rendered with the search results, the datamodel/serverside list of the richfaces indexing mechanism is not updating itself with the clientside results. So in effect in even though I do a search on a datatable with a 1000 rows and the re-render search result displays 2 rows the serverside datamodel is still containing a 1000 rows of the old data and indexes instead of the two rows for search results.

      If anyone has encountered anything similar or can point me to some documentation that will clarify what is going on I will greatly appreciate it.




      <rich:simpleTogglePanel label="Users search parameters" switchType="ajax" opened="false" ignoreDupResponses="true" eventsQueue="userSearchQueue" requestDelay="2000" ajaxSingle="true" immediate="true">

      <s:decorate template="/layout/display.xhtml">
      <ui:define name="label">Username</ui:define>
      <h:inputText id="username" value="#{exoshellUsersList.exoshellUsers.username}">
      <a:support event="onblur" reRender="panelusers,userRolesPaginator" ajaxSingle="true" ignoreDupResponses="true" action="#{exoshellUsersList.updateElementValues}"/>
      </h:inputText>
      </s:decorate>

      <s:decorate template="/layout/display.xhtml">
      <ui:define name="label">Firstname</ui:define>
      <h:inputText id="firstname" value="#{exoshellUsersList.exoshellUsers.firstname}">
      <a:support event="onblur"/>
      </h:inputText>
      </s:decorate>

      <s:decorate template="/layout/display.xhtml">
      <ui:define name="label">Lastname</ui:define>
      <h:inputText id="lastname" value="#{exoshellUsersList.exoshellUsers.lastname}">
      <a:support event="onblur"/>
      </h:inputText>
      </s:decorate>

      <s:decorate template="/layout/display.xhtml">
      <ui:define name="label">Emailaddress</ui:define>
      <h:inputText id="emailaddress" value="#{exoshellUsersList.exoshellUsers.emailaddress}">
      <a:support event="onblur"/>
      </h:inputText>
      </s:decorate>

      <s:decorate template="/layout/display.xhtml">

      </s:decorate>

      </rich:simpleTogglePanel>




      <rich:panel id="panelusers">
      <f:facet name="header">Users list</f:facet>
      <h:outputText value="There are no Users associated with this UserRole."
      rendered="#{empty exoshellUsersList.resultList}"/>

      <rich:dataTable var="_exoshellUsers"
      value="#{exoshellUsersList.resultList}"
      rendered="#{not empty exoshellUsersList.resultList}"
      rowClasses="rvgRowOne,rvgRowTwo"
      id="exoshellUsersTable" rows="10">
      <rich:column>
      <f:facet name="header">User id</f:facet>
      <h:outputText value="#{_exoshellUsers.userId}"/>
      </rich:column>
      <rich:column>
      <f:facet name="header">Username</f:facet>
      <rich:dragSupport dragIndicator=":indicator" dragType="userId" dragValue="#{_exoshellUsers}" ajaxSingle="true">
      <rich:dndParam name="label" value="#{_exoshellUsers.username}"/>
      </rich:dragSupport>
      <h:outputText value="#{_exoshellUsers.username}" />
      </rich:column>
      <h:column>
      <f:facet name="header">Registered</f:facet>
      <h:outputText value="#{_exoshellUsers.registered}">
      <s:convertDateTime type="date" dateStyle="short"/>
      </h:outputText>
      </h:column>
      <h:column>
      <f:facet name="header">Last login</f:facet>
      <h:outputText value="#{_exoshellUsers.lastLogin}">
      <s:convertDateTime type="both" dateStyle="short"/>
      </h:outputText>
      </h:column>
      <h:column>
      <f:facet name="header">Ip address</f:facet>
      <h:outputText value="#{_exoshellUsers.ipAddress}"/>
      </h:column>
      <h:column>
      <f:facet name="header">Accountenabled</f:facet>
      <h:outputText value="#{_exoshellUsers.accountenabled}"/>
      </h:column>
      <h:column>
      <f:facet name="header">Action</f:facet>
      <s:link view="/admin/ExoshellUsers.xhtml"
      id="viewexoshellUsers"
      value="View"
      propagation="none">
      <f:param name="exoshellUsersUserId"
      value="#{_exoshellUsers.userId}"/>
      <f:param name="exoshellUsersFrom"
      value="ExoshellUserRolesEdit"/>
      </s:link>
      </h:column>
      </rich:dataTable>
      </rich:panel>


      <rich:datascroller id="userRolesPaginator" maxPages="5"
      for="exoshellUsersTable" renderIfSinglePage="false" eventsQueue="usersList" ignoreDupResponses="true" requestDelay="1000">
      </rich:datascroller>

        • 1. Re: RichFaces DataTable and the mystery of the out of synch
          nmatrix9

          For the text input please only focus on the username.

          • 2. Re: RichFaces DataTable and the mystery of the out of synch
            nbelaevski

            Hi,

            Can you please post related code for exoshellUsersList bean and information on its scope?

            • 3. Re: RichFaces DataTable and the mystery of the out of synch
              nmatrix9

               

              "nbelaevski" wrote:
              Hi,

              Can you please post related code for exoshellUsersList bean and information on its scope?


              Hi nbelaevski,

              The ExoshellUsersList is using default scope (event).




              package com.domain.exoshellcms.session;

              import com.domain.exoshellcms.entity.*;


              import org.jboss.seam.annotations.Logger;
              import org.jboss.seam.annotations.Name;
              import org.jboss.seam.framework.EntityQuery;
              import org.jboss.seam.log.Log;

              import java.util.List;
              import java.util.Arrays;

              @Name("exoshellUsersList")
              public class ExoshellUsersList extends EntityQuery {

              @Logger
              private Log log;

              private static final String[] RESTRICTIONS = {
              "lower(exoshellUsers.username) like concat(lower(#{exoshellUsersList.exoshellUsers.username}),'%')",
              "lower(exoshellUsers.userpassword) like concat(lower(#{exoshellUsersList.exoshellUsers.userpassword}),'%')",
              "lower(exoshellUsers.firstname) like concat(lower(#{exoshellUsersList.exoshellUsers.firstname}),'%')",
              "lower(exoshellUsers.lastname) like concat(lower(#{exoshellUsersList.exoshellUsers.lastname}),'%')",
              "lower(exoshellUsers.emailaddress) like concat(lower(#{exoshellUsersList.exoshellUsers.emailaddress}),'%')",
              "lower(exoshellUsers.userimage) like concat(lower(#{exoshellUsersList.exoshellUsers.userimage}),'%')",
              "lower(exoshellUsers.gender) like concat(lower(#{exoshellUsersList.exoshellUsers.gender}),'%')",
              "lower(exoshellUsers.ipAddress) like concat(lower(#{exoshellUsersList.exoshellUsers.ipAddress}),'%')", };

              private ExoshellUsers exoshellUsers = new ExoshellUsers();

              @Override
              public String getEjbql() {
              return "select exoshellUsers from ExoshellUsers exoshellUsers";
              }


              public ExoshellUsers getExoshellUsers() {
              return exoshellUsers;
              }

              @Override
              public List getRestrictions() {
              return Arrays.asList(RESTRICTIONS);
              }



              }


              • 4. Re: RichFaces DataTable and the mystery of the out of synch
                nbelaevski

                This is something that won't work in plain JSF - request scoped bean with dynamic data. Please check for more: https://jira.jboss.org/jira/browse/RF-3314