• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Paging without JSTL or any other 3rd party tag

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Has anybody done paging by just using the logic:iterate tag and programmatically changing the offset attribute to go to the next or previous page? Do you have any examples?

I did use the pager taglib from jsptags.com, but then was informed (from the powers above) that I'm not allowed to use it, and that I should try and do it with the iterate tag.

Thanks
jv
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try using display tag, its a cool one

http://displaytag.sourceforge.net/11/
 
jakes vandenberg
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Dhulipalla, but unfortunately I'm not allowed to use any 3rd party tags. I know it sucks, but that is something I have to deal with now. So if anyone out here has an example to share or can point me in the direction how to use it to manipulate the offset attribute on the logic iterate tag to do paging, it will be greatly appreciated.

Thanks.
 
Ranch Hand
Posts: 181
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should use your action to control which results are sent to the screen. Then the paging hyperlinks would look like this:

<a href="/myAction.do?offset=0&length=10">Page 1</a>
<a href="/myAction.do?offset=10&length=10">Page 2</a>

More specifically it would look like this:

<logic:iterate name="MyForm" property="resultList" id="currentResult">
<bean:write name="currentResult" property="description"><br>
</logic:iterate>

<logic:iterate name="MyForm" property="numPages" id="currentPage">
<a href="<html:rewrite page="/myAction"/>?offset=<bean:write name="currentPage">&length=<bean:write name="MyForm" property="length"/>">Page <bean:write name="currentPage"/></a><br>
</logic:iterate>

This is assuming that the resultList is put in something called MyForm. That MyForm also has a list of numPages where each element in the collection is a page number. It also assumes there is a length property in the Form. There are some better ways to do it, but this should get you started.
 
jakes vandenberg
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Dom. I'll work with that.
 
reply
    Bookmark Topic Watch Topic
  • New Topic