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"
           // 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"
                              <a4j:actionparam name="pageSize" value="20"
                                  assignTo="#{messageBox.pageSize}" />
                          <a4j:commandLink value="50" reRender="messageTable"
                              <a4j:actionparam name="pageSize" value="50"
                                  assignTo="#{messageBox.pageSize}" />
                          <a4j:commandLink value="100" reRender="messageTable"
                              <a4j:actionparam name="pageSize" value="100"
                                  assignTo="#{messageBox.pageSize}" />
                      <rich:datascroller align="right" for="messageTable" maxPages="10"
                          reRender="messageTable" eventsQueue="ajx" />


      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?



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



          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.



            • 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"










                        <h:form id="form">


                                  <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"/>


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




                                                      <rich:column label="State Name">

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


                                            <f:facet name="footer">



                                                                <rich:datascroller maxPages="5" />

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

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


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

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













              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.