1 Reply Latest reply on Jan 22, 2012 6:42 PM by Wade Love

    Return a rich:dataTable with dataScroller to page one

    Wade Love Newbie

      Greetings,

       

      The environment is RichFaces 4.1 on a Tomcat 6.0.

      Here is what I have code-wise at the moment:

       

      standard.xhtml:

           <h:form>

          <rich:select

              valueChangeListener="#{standardBacker.rankChange}">

              <!-- a few f:selectItem here -->

              <a4j:ajax event="selectitem" render="tablePanel" />   

          </rich:select>

          <br /><br />

       

          <h:panelGroup id="tablePanel">

                  <rich:dataTable id="standardTable" binding="#{standardBacker.standardTable}"

                  value="#{standardBacker.curRank.standardsList}" var="stdrd" rows="8">

       

                  <rich:column>

                      <f:facet name="header">Id</f:facet>

                      <h:outputText value="#{stdrd.idNum}" />

                  </rich:column>

                <!-- additional rich:column here -->

       

                  <f:facet name="footer">

                      <rich:dataScroller id="standardScroller" binding="#{standardBacker.standardScroller}" />

                  </f:facet>

       

              </rich:dataTable>

          </h:panelGroup>

       

          </h:form>

       

       

      And here is the value change listener method in StandardBacker.java:

       

           public void rankChange(ValueChangeEvent evt) {

                // get data from the data base happens here

                  standardTable.setFirst(0);

                  standardScroller.setPage(1);

              }

          }

           // other elements and the binding UI components with getters and setters not shown.

       

      The desired result is that each time the user makes a change to the select, a new set of data is fetched and displayed in the table, with the table at page one.  The actual result is that the user can make one selection, page through it, then make another selection, and the table returns at whatever page number the user had been on previously.  If the new result set has fewer pages, it goes to the last page.

       

      I've tried other variations on what I've copied here, but all with the same outcome: the table does not go to page one after a new selection.

       

      Please advise on the correct approach.

       

      Wade.