2 Replies Latest reply on Jan 6, 2010 10:23 AM by khisanthmagus

    t:datatable first not reloading on rerender

    khisanthmagus

      First of all, we are using Richfaces 3.1.5 due to server constraints(using OC4J 10g, so we cannot upgrade JSF to 1.2 and cannot use any version of Richfaces that requires 1.2).

       

      I have a page in our application that uses a rich:tree model to select a "folder", which then looks up data in the database and populates the values for a t:datatable.  The t:datatable has the "first" attribute bound to a backing bean.  We set the value to 0 whenever the user selects a new folder, so in theory it would reset back to the first page.  Not sure if it is important for this, but the datatable also has a t:dataScroller with an embedded rich:datascroller.

       

      The problem is that when we have the rich:tree object rerender the datatable when the user selects a folder, the first attribute is never refreshed from the backing bean, and as such is saved to what it was before the user loaded a new folder.  Beyond the simple annoyance of the results not starting on the first page, this causes a major bug if the second folder has less pages to results than the first one.

       

      Say the first folder has 20 results, displayed 10 at a time.  This results in 2 pages.  If the user selects page 2 on that folder, the first row index would be 11.  Now, if the second folder you selected only has 4 results, it only has a single page.  Because the first row index is set to 11 and never pulled the 0 from the backing bean, it tries to load records 11-20 on folder 2, which don't exist.  It results in the following message with no rows displayed:

       

      4 Items found, displaying -6 items, from 11 to  4. Page 2 / 1

       

      Is there any way to fix this?

       

      Here are the tree and table being used:

      {code:xml}<rich:tree value="#{ItemGroup.treeNode}" var="groups" showConnectingLines="true" ajaxSubmitSelection="true" reRender="dataTable,itemGroupName,addNewAsset,addMultipleAsset,deleteAsset,addNewAsset2,addMultipleAsset2,deleteAsset2,searchField" nodeFace="#{groups.type}" selectedClass="treeNodeSelectedText" onselected="clearIBN()">
          <rich:treeNode type="disabled" iconLeaf="/images/iconFolderDisabled.GIF" icon="/images/iconFolderDisabled.GIF">
              <h:outputText value="#{groups.group.itemGroupName}" styleClass="treeNodeNotAllowed" />
          </rich:treeNode>
          <rich:treeNode type="node" nodeSelectListener="#{AssetManager.onItemGroupSelectionFromAssetTree}" iconLeaf="/images/iconFolder.gif" icon="/images/iconFolder.gif">
              <h:outputText value="#{groups.group.itemGroupName}" />
          </rich:treeNode>
          <rich:treeNode type="root" nodeSelectListener="#{AssetManager.onItemGroupSelectionFromAssetTree}" iconLeaf="/images/iconFolder.gif" icon="/images/iconFolder.gif">
              <h:outputText value="#{groups.group.itemGroupName}" />
          </rich:treeNode>
          <rich:treeNode type="recycle" iconLeaf="/images/recyclebin_disabled.gif" icon="/images/recyclebin_disabled.gif">
              <h:outputText value="#{groups.group.itemGroupName}" styleClass="treeNodeNotAllowed" />
          </rich:treeNode>
          <rich:treeNode type="testPackage" nodeSelectListener="#{AssetManager.onItemGroupSelectionFromAssetTree}" iconLeaf="/images/iconFolder.gif" icon="/images/iconFolder.gif">
              <h:outputText value="#{groups.group.itemGroupName}" />
          </rich:treeNode>
      </rich:tree>
      {code}
      {code:xml}<t:dataTable id="dataTable"
      value="#{assetManagementBean.assetUnitTable.rows}"
      var="assetUnit"
      rows="#{dataModelBean.dataTableRowSizeMap.assetManagementAssetsTable}"
      first="#{dataModelBean.firstIndex}"
      cellspacing="2"
      cellpadding="4"
      columnClasses="a50pxColumn, a200pxColumn, a80pxColumn, a200pxColumn"
      styleClass="listtable"
      style="width:100%;"
      rowClasses=",lightshade"
      rowOnMouseOver="javascript:this.style.background='rgb(214,231,255)';"
      rowOnMouseOut="javascript:setRowHighlight(this,rowIndex,'white','#DBECF1');">

      *columns*

      <f:facet name="footer">
      <%@ include file="/WEB-INF/layout/paginator.jspf" %>
      </f:facet>
      {code}