2 Replies Latest reply on Jul 27, 2009 5:16 PM by Yasser Hawari

    Pagination and EntityQuery

    Timothy Whitehead Newbie

      I have some typical search pages similar to those produced by seam-gen. I am using the paginator produced by seam-gen (converted to a facelet)
      However I refresh the list using ajax from richfaces rather than a search button.
      The problem was that if you page through the results then change the search parameters and the results have less pages than the current page you are on, then it wrongly displays the 'No results' message.
      I have solved it by putting the following code in my List bean. I think it (or something similar) should really be a standard part of the seam EntityQuery code as it makes no sense to allow someone to request a page beyond the end of the results.



      public List<Flight> getResultList() {
           List<Flight> flight = super.getResultList();
           if (getFirstResult() != null && getFirstResult() > 0 
                     && (flight == null ||  flight.size() == 0)) {
                setFirstResult(0);
                refresh();
           }
           return super.getResultList();
      }