5 Replies Latest reply on Sep 5, 2009 9:11 AM by Nick Belaevski

    Selection from ScrollableDataTable returns RawData of the pr

    Mike Mike Newbie

      Hi All,

      I am new to RichFaces and I have a problem with scrollableDataTable, which in my opinion is mainly related to not being familiar with the component.

      I am trying to create an external custom filter e.g. filter by name in a separate panel and reRender a ScrollableDataTable with user data, after that select the user and display additional information for him.

      Declaration of the ScrollableDataTable:
      <rich:scrollableDataTable rowKeyVar="rkv" frozenColCount="1"
      height="200px" width="100%" id="table" rows="30"
      columnClasses="col" value="#{UserManager_Backing.users}"
      binding="#{UserManager_Backing.table}"
      selection="#{UserManager_Backing.selection}" var="record1">
      <a4j:support event="onRowClick"
      action="#{UserManager_Backing.handleSelection}"
      reRender="UserDetails" />
      <rich:column>
      <f:facet name="header">
      <h:outputText value="ID" />
      </f:facet>
      <h:outputText value="#{record1.id}" id="id" />
      </rich:column>
      ...
      </rich:scrollableDataTable>

      Search Pannel:
      <h:panelGrid columns="4" styleClass="rich-container rich-text-general">
      <h:outputLabel value="User Name" for="uname" />
      <h:inputText id="uname" binding="#{UserManager_Backing.uname}"/>
      <rich:spacer width="15" height="10" />

      <a4j:commandButton value="Search" action="#{UserManager_Backing.Search}"
      reRender="table, UserDetails"/>
      </h:panelGrid>


      Every thing is fine in the beginng, the Table is rendered Ok with all users, when you click on user, the UserDetails is rerendered and everything is fine :)
      When I try to filter by entering user name, the Search button is sending the name and I am retrieving the data from the database, the scrollableDataTable is reRender-ed, the UserDetails tab is reRender-ed and everything is fine again.

      But when I select an user from the scrollableDataTable the selection returns me the details for the user that was displayed on the initial data load.

      I think that the problem is not in the component, but I am not doing something correctly.

      Here is the code for loading of the users:
      public List getUsers()
      {
      List result = null;

      try
      {
      if (mFilter)
      {
      result = new UserManager().filterUsers(mUserName);
      }
      else
      {
      result = new UserManager().getUsers();
      }
      }
      catch (Exception e)
      {
      // TODO Auto-generated catch block
      e.printStackTrace();
      }

      return result;
      }

      Here is the way that I am getting the selection:
      public void handleSelection()
      {
      Iterator keys = mSelection.getKeys();
      while(keys.hasNext())
      {
      Object key = keys.next();
      mTable.setRowKey(key);

      if (mTable.isRowAvailable())
      {
      mSelectedUserID = ((User)mTable.getRowData()).getId();
      }
      }
      }

      It looks like the RowData contains the initially loaded Users.

      Do you have any idea where I am wrong?

      Thanks in Advance,

      Dimitar.