All the grunt work is done in our business layer, which we customised specifically for iBatis/displaytag. This is probably a no-no in programming practice, but it fits well for what we need.
Z.
Fabrizio Gianneschi wrote:
I like displaytag, too, but I was not able to use it in this case ('Google like' list), because it doesn't have a way to force by hand the number of results returned by the count query.
If I remember well, page numbers were autocalculated by the tag itself, using the list passed as a parameter. So we switched to another less featured but simpler tag (Pager Taglib) and used displaytag only for small lists.
It would be great if you have a working solution that we didn't found...
Is this thread starting to be a little off-topic? :)
Fabrizio
-----Messaggio originale----- Da: Zoran Avtarovski [mailto:[EMAIL PROTECTED] Inviato: luned� 21 marzo 2005 11.23 A: [email protected] Oggetto: Re: R: PaginatedList & 'google like' results
DisplayTag (http://displaytag.sourceforge.net/) in combination with iBatis is fantastic. You don't have to store the list in the session and if you design your app well the ibatis cache reduces your db hits to a minimum, improving performance. Plus it has host of added extras such as dynamic sorting, exporting different formats, grouping and a load more.
I had no problems implementing it and the forums on sourceforge have been great.
Z.
Guido Garc�a Bernardo wrote:
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 com.ibatis.common.util.PaginatedList.
My ListWrapper implements java.util.List and contains: - isFirstPage/isLastPage/isMiddlePage, getPageIndex, getPageSize methods, so my JSP is 'compatible' with the previous aproach using PaginatedList. - getRowCount, getPageCount, so now I can do a 'google like' paginated list.
Regards.
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 expose.
I think you should put the two queries in the same transaction, also.
Regards, Fabrizio
-----Messaggio originale----- Da: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Inviato: venerd� 18 marzo 2005 12.13 A: [email protected] Oggetto: PaginatedList & 'google like' results
Hi,
I am using ibatis PaginatedList functionality for paging through search results, and I would like to add the ability for a user to go to the last page of the results (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 from..." and a new "select count(*) from...") to achieve it?
Thank you very much, Guido.
- Guido Garc�a Bernardo - [EMAIL PROTECTED] ITDEUSTO - Valladolid

