That's nice. The problem in my case is that the Architects in my company does not allow us to put database layer especific code into the web layer code. But, if it's not a problem, thats nice. But remember, if one day you decide to chance iBatis for another framework, you will have to touch the web code (the action in your example).
-----Mensagem original----- De: Brice Ruth [mailto:[EMAIL PROTECTED] Enviada em: sexta-feira, 18 de mar�o de 2005 11:25 Para: [email protected] Assunto: Re: PaginatedList & 'google like' results The product catalogs on www.powersentry.com, www.newpoint.com, www.zincklysbro.dk, and www.wilkinsonswordgarden.com all use PaginatedList to provide the Page [1] 2 3 4 ... functionality. I have a simple Action that looks like this: public ActionForward gotoPage( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { DynaActionForm myForm = (DynaActionForm) form; // Get PRODUCT_INFO_KEY object from session PaginatedList products = (PaginatedList) request.getSession().getAttribute(Constants.PRODUCT_LIST_KEY); if (products != null) { try { String page = (String) myForm.get("page"); if (page.equalsIgnoreCase("next")) { products.nextPage(); } else if (page.equalsIgnoreCase("previous")) { products.previousPage(); } else { int pageNum = new Integer(page).intValue(); products.gotoPage(pageNum); } request.setAttribute(Constants.PRODUCT_LIST_CURRENT_PAGE,new Integer(products.getPageIndex())); return mapping.findForward("success.showCategory"); } catch (NumberFormatException e) { return mapping.findForward("browse"); } catch (RuntimeException e) { return mapping.findForward("browse"); } } else { return mapping.findForward("browse"); } } To make this work, when I do the initial query to populate the PaginatedList, I do as you indicated - one query for the objects, one query for the count. To hide this double-step, you could put that in your DAO, if you're using one (I am not). Brice On Fri, 18 Mar 2005 12:12:31 +0100, Guido Garc�a Bernardo <[EMAIL PROTECTED]> wrote: > 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] > Tfn. +34 983 54 89 08 > ITDEUSTO - Valladolid > >

