6 Replies Latest reply on Apr 14, 2010 3:33 PM by thokuest

    rich:dataScroller page

      Can someone tell me how to get the current page of a rich:dataScroller in the backing bean.  When I click on a page, I want that value to print in the backing bean.


        • 1. Re: rich:dataScroller page
          asookazian

          Here is the example from http://docs.jboss.org/richfaces/latest_3.3.X/en/devguide/html/rich_datascroller.html:


          You need to write a getter and setter for this value: dataTableScrollerBean.scrollerPage


          <h:form id="myForm">
          
              <rich:dataTable id="carList" rows="7" value="#{dataTableScrollerBean.allCars}" var="category">
          
                  <f:facet name="header">
          
                      <rich:columnGroup>
          
                          <h:column>
          
                              <h:outputText value="Make" />
          
                          </h:column>
          
                          <h:column>
          
                              <h:outputText value="Model" />
          
                          </h:column>
          
                          <h:column>
          
                              <h:outputText value="Price" />
          
                          </h:column>
          
                      </rich:columnGroup>
          
                  </f:facet>
          
                  <h:column>
          
                      <h:outputText value="#{category.make}" />
          
                  </h:column>
          
                  <h:column>
          
                      <h:outputText value="#{category.model}" />
          
                  </h:column>
          
                  <h:column>
          
                      <h:outputText value="#{category.price}" />
          
                  </h:column>
          
              </rich:dataTable>
          
              <rich:datascroller id="sc2" for="carList" reRender="sc1" maxPages="7" page="#{dataTableScrollerBean.scrollerPage}" />
          
              <h:panelGrid>
          
                  <h:panelGroup>
          
                      <h:outputText value="Set current page number:" />
          
                      <h:inputText value="#{dataTableScrollerBean.scrollerPage}" id="sc1" size="1"/>
          
                      <h:commandButton value="Set" />
          
                  </h:panelGroup>
          
              </h:panelGrid>
          
          </h:form>

          • 2. Re: rich:dataScroller page

            Thanks for the reply.  Can you let me know if scrollerPage in dataTableScrollerBean is of what type, String or Integer, since I get type mismatch error.




            Sai

            • 3. Re: rich:dataScroller page

              wouldn't the scrollerPage be the page that we were on rather than the page we are trying to go to.  For example, if you are on page1, and want to go to Page 2.  Will scrollerPage store 1 or 2.


              If it stores 1 then it will be of no help to me.  I want to get the value of 2 in the bean.



              thanks
              Sai

              • 4. Re: rich:dataScroller page

                Could someone also paste the backing bean part of the code where in scrollerPage is defined and getter and setters are generated.



                thanks
                Sai

                • 5. Re: rich:dataScroller page
                  asookazian

                  all the code should be available in the RichFaces examples distro.  ask on the RF forum.

                  • 6. Re: rich:dataScroller page
                    thokuest

                    Sai Burgula wrote on Apr 13, 2010 19:02:

                    Can you let me know if scrollerPage in dataTableScrollerBean is of what type, String or Integer, since I get type mismatch error.


                    Look at the according Tag Information. The expression must evaluate to int. The stored value equals the number of the currently shown page.




                    Example




                    • xhtml



                    <rich:dataTable>
                        <f:facet name="footer">
                            <rich:dataScroller page="#{dataTableScrollerBean.scrollerPage}" />
                        </f:facet>
                    </rich:dataTable>




                    • Bean



                    @Name("dataTableScrollerBean")
                    public class DataTableScrollerBean {
                        private int scrollerPage;
                    
                        public int getScrollerPage() {
                            return this.scrollerPage;
                        }
                    
                        public void setScrollerPage(int scrollerPage) {
                            this.scrollerPage = scrollerPage;
                        }
                    
                    //  [...]
                    }