4 Replies Latest reply on Mar 18, 2011 7:05 AM by hantsy bai

    How to set page size with dataScroller...

    hantsy bai Master

      Hi, everybody

      I want to set page size by click a link, but it does not work.

       

      I used Seam 2.2.1, Richfaces 3.3 in the project.

       

      The following is the code fragment.

       

      <rich:extendedDataTable id="messageTable"
              value="#{messageBox.dataModel}" 
              var="m" 
      
              rows="#{messageBox.pageSize}">
      
           // columns...
      
              <f:facet name="footer">
                  <h:panelGroup layout="block">
                      <h:panelGroup styleClass="pageSizeLink" layout="block">
                          <div>List results per page:</div>
                          <a4j:commandLink value="20" reRender="messageTable"
                              ajaxSingle="true">
                              <a4j:actionparam name="pageSize" value="20"
                                  assignTo="#{messageBox.pageSize}" />
                          </a4j:commandLink>
                          <a4j:commandLink value="50" reRender="messageTable"
                              ajaxSingle="true">
                              <a4j:actionparam name="pageSize" value="50"
                                  assignTo="#{messageBox.pageSize}" />
                          </a4j:commandLink>
                          <a4j:commandLink value="100" reRender="messageTable"
                              ajaxSingle="true">
                              <a4j:actionparam name="pageSize" value="100"
                                  assignTo="#{messageBox.pageSize}" />
                          </a4j:commandLink>
                      </h:panelGroup>
                      <rich:datascroller align="right" for="messageTable" maxPages="10"
                          reRender="messageTable" eventsQueue="ajx" />
                  </h:panelGroup>
              </f:facet>
      
      
      
          </rich:extendedDataTable>
      

       

      I use a Seam  Session scoped messageBox here, it has a int field pagesize...

       

      I have found  another similiar problem here, http://www.coderanch.com/t/454868/JSF/java/Seam-RichFaces-extendedDataTable-datascroller-changeable

       

      How to resovle the problem?

       

      Thanks.

        • 1. How to set page size with dataScroller...
          Nick Belaevski Master

          Hi,

           

          Try wrapping table into a4j:outputPanel and re-render it.

          • 2. Re: How to set page size with dataScroller...
            hantsy bai Master

            Before I posted it, I have tried the approache u said. There is an outside h:panelGroup to wrap the table, I set the panelGroup id as reRender value, it did not work.

            I have just tried that like u said(add another a4j:outputPanel to wrap it) , it still did not work.

             

            Thanks.

            • 3. Re: How to set page size with dataScroller...
              Ilya Shaikovsky Master

              <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

              <html xmlns="http://www.w3.org/1999/xhtml"

                        xmlns:ui="http://java.sun.com/jsf/facelets"

                        xmlns:h="http://java.sun.com/jsf/html"

                        xmlns:f="http://java.sun.com/jsf/core"

                        xmlns:a4j="http://richfaces.org/a4j"

                        xmlns:rich="http://richfaces.org/rich"

                    xmlns:s="http://jboss.com/products/seam/taglib">

               

               

              <ui:composition>

                        <h:form id="form">

                                  <a4j:outputPanel>

                                  <h:panelGrid columns="2" columnClasses="top , top">

                                            <rich:extendedDataTable rowKeyConverter="#{entityConverter}"

                                                      value="#{capitalsBean.capitals}" var="cap" id="table"

                                                      width="580px" height="400px" enableContextMenu="false"

                                                      rows = "#{capitalsBean.rows}">

               

               

                                                      <rich:column sortable="true" sortBy="#{cap.state}" id="col_2"

                                                                filterBy="#{cap.state}" filterEvent="onkeyup" width="170px"

                                                                label="State Name">

                                                                <f:facet name="header">

                                                                          <h:outputText value="State Name" id="state_name"/>

                                                                </f:facet>

                                                                          <h:outputText value="#{cap.state}"/>

               

               

                                                      </rich:column>

                                                      <rich:column label="State Name">

                                                                <h:outputText value="#{cap.state}" id="out"/>

                                                      </rich:column>

                                            <f:facet name="footer">

                                                      <h:panelGroup>

                                                      qweqwe

                                                                <rich:datascroller maxPages="5" />

                                                                <a4j:commandLink value="10" reRender="table" ajaxSingle="true">

                                                                          <a4j:actionparam assignTo="#{capitalsBean.rows}" value="10" name="p1"/>

                                                                </a4j:commandLink>

                                                                <a4j:commandLink value="20" reRender="table" ajaxSingle="true">

                                                                          <a4j:actionparam assignTo="#{capitalsBean.rows}" value="20" name="p2"/>

                                                                </a4j:commandLink>

                                                      </h:panelGroup>

                                            </f:facet>

                                            </rich:extendedDataTable>

                                  </h:panelGrid>

                                  </a4j:outputPanel>

                        </h:form>

              </ui:composition>

               

              </html>

               

               

              Works for me in 3.3.3 latest code.

               

              Also Nick, I checked for 4.x and it works there also for both tables.

              • 4. Re: How to set page size with dataScroller...
                hantsy bai Master

                There is a very small mistake in my code...I forgot generate the set method of the pageSize field...it works now.

                 

                Thank u all.