wood burning stoves 2.0*
The moose likes Struts and the fly likes Paging without JSTL or any other 3rd party tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Paging without JSTL or any other 3rd party tag" Watch "Paging without JSTL or any other 3rd party tag" New topic
Author

Paging without JSTL or any other 3rd party tag

jakes vandenberg
Greenhorn

Joined: Nov 05, 2004
Posts: 14
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
Dhulipalla
Greenhorn

Joined: Aug 02, 2006
Posts: 4
Try using display tag, its a cool one

http://displaytag.sourceforge.net/11/
jakes vandenberg
Greenhorn

Joined: Nov 05, 2004
Posts: 14
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.
Dom Lassy
Ranch Hand

Joined: May 05, 2006
Posts: 181
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

Joined: Nov 05, 2004
Posts: 14
Thanks Dom. I'll work with that.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Paging without JSTL or any other 3rd party tag
 
Similar Threads
The pagefile fragment competition.
How to do Paging
Page Navigation
paging concept
how to use IBatis to paging in jsp?