ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Guido García Bernardo <ggb...@tid.es>
Subject Re: R: PaginatedList & 'google like' results
Date Mon, 21 Mar 2005 09:15:51 GMT
Thank you very much.
I don't like the Brice Ruth idea of using the session to store the 
PaginatedList object.

Finally I've done it this way, using a ListWrapper instead of using a 

My ListWrapper implements java.util.List and contains:
- isFirstPage/isLastPage/isMiddlePage, getPageIndex, getPageSize 
methods, so my JSP is 'compatible' with the previous aproach using 
- getRowCount, getPageCount, so now I can do a 'google like' paginated list.


Fabrizio Gianneschi wrote:

>I'm used to execute two queries (count + select) for each stament in this
>kind of situations.
>The code is hidden in the DAOs, so the business/web layers are not aware of
>the strategy.
>The following is the generic method I use:
>private List executePagedQuery(Object params, int offset,
>                 int limit, boolean countResults, String query, String
>countQuery) {
>        List l = super.getList(query, params, offset, limit);
>        if (countResults) {
>            Integer size = (Integer) super.getObject(countQuery, params);
>            ListWrapper wrapper = new ListWrapper(l, size);
>            return wrapper;
>        } else {
>            return l;
>        }
>    }
>"ListWrapper" is a simple java.util.List wrapper that espose a constructor,
>used to inject the maximum number of results, which PaginatedList doesn't
>I think you should put the two queries in the same transaction, also.
>-----Messaggio originale-----
>Da: ggb275@tid.es [mailto:ggb275@tid.es]
>Inviato: venerdì 18 marzo 2005 12.13
>A: ibatis-user-java@incubator.apache.org
>Oggetto: PaginatedList & 'google like' results
>I am using ibatis PaginatedList functionality for paging through search
>and I would like to add the ability for a user to go to the last page of the
>(something like Google results) instead of having to page through big result
>sets as
>it is done in JPetStore4:
>  <logic:notEqual name="orderBean" property="orderList.firstPage"
>value="true" >
>    <a href="switchOrderPage.shtml?pageDirection=previous">PREV</a>
>  </logic:notEqual>
>  <logic:notEqual name="orderBean" property="orderList.lastPage"
>value="true" >
>    <a href="switchOrderPage.shtml?pageDirection=next">NEXT</a>
>  </logic:notEqual>
>Is this possible or should I do two queries (my actual "select fields
>and a new "select count(*) from...") to achieve it?
>Thank you very much,
Guido García Bernardo - ggarciab@itdeusto.com
ITDEUSTO - Valladolid

View raw message