0 Replies Latest reply on Mar 1, 2007 7:00 AM by Jonas Erma

    Pagination With Query Objects Bug?

    Jonas Erma Newbie

      Hi all!

      I think I discovered a bug with the pagination logic of Query objects.

      I have a query object comments defined in my components.xml. max-results param is set to 5 and I know that I have 10 comments in the DB. I can use the following code for the rendering of a "next page" link:

      <s:link view="/comments.xhtml" rendered="#{comments.nextExists}" value="Next Page">
       <f:param name="firstResult" value="#{comments.nextFirstResult}"/>
      </s:link>


      Now, when I'm already browsing the second and last page, i.e. with firstResult param set to 5, a "next page" link is still there. When I click on "next page", firstResult is set to 10 and the query object returns an empty list.

      I went through the Query.java code and found this implementation for isNextExists():

      public boolean isNextExists()
      {
       return getResultList()!=null &&
       getResultList().size() == getMaxResults();
      
      }


      I think this code should consider the resultCount as well, so that getNextFirstResult() doesn't return a value equal or greater than the resultCount.

      Isnt't this the expected behavior for you guys?

      tazman