1 Reply Latest reply on Aug 21, 2008 9:09 PM by Valerie Griffin

    New TopicWorking ICEfaces paginator in seam-gen'd code

    Valerie Griffin Newbie
      This info is cross-posted in icefaces.org.

      I noticed several questions about using a dataPaginator in a Seam application when I was looking for a way to do just that. The example here uses jspx and doesn't start from a generated application. Therefore, I'm posting what I did in case someone else wants to use it. I actually went one step further and changed the template used by seam-gen. I'll post that as a reply to this message.

      I recognize that some of what I did reduces skinablity and removes internationalization.

      The first thing I tries was to copy the paginator part from the sample code I downloaded from this forum into the TblList.xhtml file generated by Seam, changing the "for" value appropriately.

      Of course that didn't work.
      I recognize that some of what I did reduces skinablity and removes internationalization.

      The first thing I tries was to copy the paginator part from the sample code I downloaded from this forum into the TblList.xhtml file generated by Seam, changing the "for" value appropriately.

      Of course that didn't work.

      I ran into two relatively easy problems. It didn't seem to find the image so I copied the images to the view/img directory and use the value parm with file names relative to the view directory. This lets me deploy more easily to the production system where the code will actually run. It also puts these images with the other images used by the application. Rather than track down the messages inside the ICEfaces sample, I changed the title fields to their English text. If you want to keep internationalization and skins, you'll have to use something more like the original code.

      Then, it complained about a form. I changed the <ice:form> to include the dataPaginators.

      I had to adjust some of the display settings to get everything to look the way I wanted it to look.

      With all of that, it showed me a display that was tantalizingly close. I got a nice 25-row table with paginator controls that didn't seem to do anything. Also, there were no page links shown in the paginator. This one was a LOT harder to figure out. Ultimately, it was the display length of 25 rows that provided the clue. The maxResults value in action/TblList.java was being overridden by code used to create Seam's less-capable pagination controls. Once I removed that code, the paginator worked!

      I added an enhancement to let the user specify the number of rows in a page by adding a maxDisplayRows value to action/TblList.java and using it in the dataTable.

      With that prolog, here's the code:

      action/TblList.java:

      Remove getMaxResults

      Insert:

           private Integer maxDisplayRows = new Integer(25);

           public Integer getMaxDisplayRows() {
                return maxDisplayRows;
           }

           public void setMaxDisplayRows(Integer maxDisplayRows) {
                this.maxDisplayRows = maxDisplayRows;
           }

      view/TblList.xhtml:

          <ice:dataTable id="tblListTableId"
                        var="tbl"
                      value="#{tblList.resultList}"
                  resizable="true"
              columnClasses="allCols"
                       rows="#{tblList.maxDisplayRows}"
                   rendered="#{not empty tblList.resultList}">
              <ice:column ...
             
              no changes here....
             
              </ice:column>
          </ice:dataTable>

          </div>
      </ice:panelGroup>

          <div>
              <ice:panelGroup styleClass="clearer"/>

                  <!-- Set up the buttons and links for browsing through the table
                   fastStep means No. of pages to fast forward or rewind: 3
                   paginatorMaxPages means No. of direct links to pages: 4 -->
                <ice:panelGroup style="left;width:420px;">
                  <center>
                  <ice:dataPaginator id="tblListPager"
                         rendered="#{not empty tblList.resultList}"
                         for="tblListTableId"
                         vertical="false"
                         fastStep="3"
                         paginator="true"
                         paginatorMaxPages="4">
                      <f:facet name="first">
                          <ice:graphicImage id="firstpage_1"
                                            value="img/arrow-first.gif"
                                            style="border:none;"
                                            title="First"/>
                      </f:facet>
                      <f:facet name="last">
                          <ice:graphicImage id="lastpage_1"
                                            value="img/arrow-last.gif"
                                            style="border:none;"
                                            title="Last"/>
                      </f:facet>
                      <f:facet name="previous">
                          <ice:graphicImage id="previouspage_1"
                                            value="img/arrow-previous.gif"
                                            style="border:none;"
                                            title="Previous"/>
                      </f:facet>
                      <f:facet name="next">
                          <ice:graphicImage id="nextpage_1"
                                            value="img/arrow-next.gif"
                                            style="border:none;"
                                            title="Next"/>
                      </f:facet>
                      <f:facet name="fastforward">
                          <ice:graphicImage id="fastforward_1"
                                            value="img/arrow-ff.gif"
                                            style="border:none;"
                                            title="Fast Forward"/>
                      </f:facet>
                      <f:facet name="fastrewind">
                          <ice:graphicImage id="fastrewind_1"
                                            value="img/arrow-fr.gif"
                                            style="border:none;"
                                            title="Fast Reverse"/>
                      </f:facet>
                  </ice:dataPaginator>
                  </center>
                 
                  <!-- summarize pagination info -->
                 
                     <ice:dataPaginator id="tblListPageSumm" for="tblListTableId"
                            rowsCountVar="rowsCount"
                            displayedRowsCountVar="displayedRowsCount"
                            firstRowIndexVar="firstRowIndex"
                            lastRowIndexVar="lastRowIndex"
                            pageCountVar="pageCount"
                            pageIndexVar="pageIndex">
                        <ice:outputFormat
                                styleClass="standard"
                                value="{0} entries found, displaying {1} entrie(s), from {2} to {3}. Page {4} / {5}.">
                            <f:param value="#{rowsCount}"/>
                            <f:param value="#{displayedRowsCount}"/>
                            <f:param value="#{firstRowIndex}"/>
                            <f:param value="#{lastRowIndex}"/>
                            <f:param value="#{pageIndex}"/>
                            <f:param value="#{pageCount}"/>
                        </ice:outputFormat>
                    </ice:dataPaginator>
              </ice:panelGroup>
          </div>
          </ice:form>


      Remove the generated pager code.
        • 1. Re: New TopicWorking ICEfaces paginator in seam-gen'd code
          Valerie Griffin Newbie
          I changed seam-gen/icefaces-staging/src/EntityList.java.ftl where the code is directly copied into the source files.

          Remove gesMaxResults.

          Insert:

              private Integer maxDisplayRows = new Integer(25);
               
              public Integer getMaxDisplayRows()
              {
                  return maxDisplayRows;
              }

              public void setMaxDisplayRows(Integer maxDisplayRows)
              {
                  this.maxDisplayRows = maxDisplayRows;
              }

          I added ICEfaces arrow*gif files to seam-gen/icefaces-staging/view/img

          Include in ice:dataTable generation:

                           rows="${'#'}{${listName}.maxDisplayRows}"

          remove:

              </ice:form>

          Replace <div class="tableControl"> - </div> with:

              <div>
                  <ice:panelGroup styleClass="clearer"/>

                      <!-- Set up the buttons and links for browsing through the table
                       fastStep means No. of pages to fast forward or rewind: 3
                       paginatorMaxPages means No. of direct links to pages: 4 -->
                    <ice:panelGroup style="left;width:420px;">
                      <center>
                      <ice:dataPaginator id="${listName}Pager"
                             rendered="${'#'}{not empty ${listName}.resultList}"
                             for="${listName}TableId"
                             vertical="false"
                             fastStep="3"
                             paginator="true"
                             paginatorMaxPages="4">
                          <f:facet name="first">
                              <ice:graphicImage id="firstpage_1"
                                                value="img/arrow-first.gif"
                                                style="border:none;"
                                                title="First"/>
                          </f:facet>
                          <f:facet name="last">
                              <ice:graphicImage id="lastpage_1"
                                                value="img/arrow-last.gif"
                                                style="border:none;"
                                                title="Last"/>
                          </f:facet>
                          <f:facet name="previous">
                              <ice:graphicImage id="previouspage_1"
                                                value="img/arrow-previous.gif"
                                                style="border:none;"
                                                title="Previous"/>
                          </f:facet>
                          <f:facet name="next">
                              <ice:graphicImage id="nextpage_1"
                                                value="img/arrow-next.gif"
                                                style="border:none;"
                                                title="Next"/>
                          </f:facet>
                          <f:facet name="fastforward">
                              <ice:graphicImage id="fastforward_1"
                                                value="img/arrow-ff.gif"
                                                style="border:none;"
                                                title="Fast Forward"/>
                          </f:facet>
                          <f:facet name="fastrewind">
                              <ice:graphicImage id="fastrewind_1"
                                                value="img/arrow-fr.gif"
                                                style="border:none;"
                                                title="Fast Reverse"/>
                          </f:facet>
                      </ice:dataPaginator>
                      </center>
                     
                      <!-- summarize pagination info -->
                     
                         <ice:dataPaginator id="${listName}PageSumm" for="${listName}TableId"
                                rowsCountVar="rowsCount"
                                displayedRowsCountVar="displayedRowsCount"
                                firstRowIndexVar="firstRowIndex"
                                lastRowIndexVar="lastRowIndex"
                                pageCountVar="pageCount"
                                pageIndexVar="pageIndex">
                            <ice:outputFormat
                                    styleClass="standard"
                                    value="{0} entries found, displaying {1} entrie(s), from {2} to {3}. Page {4} / {5}.">
                                <f:param value="${'#'}{rowsCount}"/>
                                <f:param value="${'#'}{displayedRowsCount}"/>
                                <f:param value="${'#'}{firstRowIndex}"/>
                                <f:param value="${'#'}{lastRowIndex}"/>
                                <f:param value="${'#'}{pageIndex}"/>
                                <f:param value="${'#'}{pageCount}"/>
                            </ice:outputFormat>
                        </ice:dataPaginator>
                  </ice:panelGroup>
              </div>
              </ice:form>