This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes Displaying 1-9 using pager taglib Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Displaying 1-9 using pager taglib" Watch "Displaying 1-9 using pager taglib" New topic

Displaying 1-9 using pager taglib

manish ahuja
Ranch Hand

Joined: Oct 23, 2003
Posts: 312
Hi All

I am using the pager taglib from {}

I have managed to get in the place the previous & next functionality & was able to paginate with the entire collection.

Now we have a new requirement where in the functionality is very similar to Javaranch search page where at the top of the search results set we get to see something like this
Displaying Topics 1 - 9 (9 total)

I also want to display something similar. How do I implement the same using the pager taglib. I would want to display the start record number & the end record number on each page


Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
Not really a Struts question...but I have implemented something similar. It was several years ago that I wrote the code, so I do not remember the details. The best advice I have it to go the demo page:

You will notice that the AllTheWeb and the Yahoo! sample layouts show something similar. Open the war file (pager-taglib-2.0.war) using a program such as WinZip and you will see that it contains the sample jsp files (alltheweb.jsp and yahoo.jsp). Here is a snippet of the AllTheWeb example:

- Brent
manish ahuja
Ranch Hand

Joined: Oct 23, 2003
Posts: 312
Hi Brent

Thanks for the solution.

First of all sorry for using this forum. But I did not find any other place where there was so much discussion on pager taglib.

The solution works excellent. But the <pg:index> tag works only if there is more than 1 page. Say if I have resultset which returns only 1 page in that case I am not able to show something like this
Showing results 1-3 of 3
How can I handle this using pager taglib

It is sorta covered in the JavaRanch Style Guide.
subject: Displaying 1-9 using pager taglib
Similar Threads
controlling jsp:forward
How to get the pagenumber when using <pager> taglib?
Dispalying Page Number using <pg:pager> taglib
Having Problems with Data Table and Pager component in JSF
Implementing Paging