6 Replies Latest reply on Feb 7, 2008 10:24 AM by vicky123

    Pagination problem

    vicky123

      Hi All,
      I am writing code for pagination, when i try to call a method with a parameter the value of that parameter is always 0 in the bean. But when I hard code the value it takes the hardcoded value.

      My Code:-

      <h:panelGrid columns="10">
       <c:forEach items="#{userManage.pageLinks}" var="link">
       <s:link action="#{userManage.loadSelectedPage(link)}" value="#{link}">
       </s:link>
       </c:forEach>
      </h:panelGrid>
      


      pageLinks is a collection of Integer.

      When I hard code the value:-

      <h:panelGrid columns="10">
       <c:forEach items="#{userManage.pageLinks}" var="link">
       <s:link action="#{userManage.loadSelectedPage('1')}" value="#{link}">
       </s:link>
       </c:forEach>
      </h:panelGrid>
      


      Session bean-
      public void loadSelectedPage(int requestedPage) {
       this.requestedPage = requestedPage;
       log.info("Requested page number = " + this.requestedPage); // always gives 0
       fetchUsersDetails();
       }
      


      Am I doing something wrong in here?

      Thanks in advance.

      -Vivek

        • 1. Re: Pagination problem
          vicky123

          page links are generated properly

          varible 'link' is 0 when i click on the link.

          <h:panelGrid columns="10">
           <c:forEach items="#{userManage.pageLinks}" var="link">
           <s:link action="#{userManage.loadSelectedPage(link)}" value="#{link}">
           </s:link>
           </c:forEach>
          </h:panelGrid>


          • 2. Re: Pagination problem
            dexjam

            You problably may want to try <ui:repeat />. As far as i can remember there are issues with forEach ...

            • 3. Re: Pagination problem
              vicky123

               

              You problably may want to try <ui:repeat />. As far as i can remember there are issues with forEach ...


              Same problem with <ui:repeat>...

              Can't I have an arrayList of Integer?
              Is it required to have an arrayList of beans?

              Thanks for the reply


              • 4. Re: Pagination problem
                vicky123

                Can anyone help me solve this problem?

                • 5. Re: Pagination problem
                  shane.bryzak

                  When invoking your method, "link" will be evaluated against the current contextual state, not the transient value that it was assigned during the rendering of your page. An alternative is to instead use a request param (or a page param) and write your link like this:

                  <s:link action="#{userManage.loadSelectedPage}" value="#{link}">
                   <f:param name="page" value="#{link}"/>
                  </s:link>


                  • 6. Re: Pagination problem
                    vicky123

                    Thanks shane
                    It worked.