Auto-paging of long lists

120 items found, displaying 41 to 50.[First/Prev] 1, 2, 3, 4, 5, 6, 7, 8 [Next/Last]
ID Name Email Status
99131 Accusam Sed accusam-sed@Lorem.com KASD
82286 Sed Justo sed-justo@est.com LABORE
14497 Invidunt Sadipscing invidunt-sadipscing@dolores.com LOREM
68386 Invidunt Erat invidunt-erat@sit.com TEMPOR
58871 Lorem Amet Lorem-amet@sanctus.com ET
10625 Ut Et ut-et@est.com DUO
90679 Et Sanctus et-sanctus@et.com VERO
37836 Clita Sea clita-sea@ut.com SED
12554 Tempor Clita tempor-clita@sed.com LOREM
408 Justo Aliquyam justo-aliquyam@sea.com AMET

Ok, you have made a query that returns you back a list of 120 elements, but you don't want to show the user all 120 items at once, you want to allow them to page through the results (pretend 120 is really 1200 or 12000).

One of the most common web UI techniques is to show a page of data (items 1-10), and then let the user click on a page number and allow them to scroll through the list. Include the "pagesize" attribute to your table tag, and the tag takes care of the reset.

You need to design your page, so that the JSP page with the table tag can be reloaded without reloading the entire list of entries. It is assumed that you have gone through the action of loading the list in a previous page (or action in Struts-speak), and then redirected the person to the page with the table tag on it.

You need to do this because the table tag's various page links will all point to the page the table tag is on (but also providing various parameters - which the table tag itself parses and deals with). So if you are doing any processing on the page, it can either 1) simply not work because the table tag doesn't know what parameters to pass for your processing, or 2) slow things down because you would be reloading the entire list on each page, rather then just showing a subset of the list. It sounds confusing, but that's just because I do a poor job of explaining it...

By default, the table tag tries to figure out what the URL is for the page it is on by calling the request.getRequestURI() method, but this will not always return a correct answer in environment where you are forwarding a request around before arriving at the JSP that is to be displayed (like struts). In those cases, you need to tell the table tag what it's URL is via the "requestURI" attribute.

All the parameters received in the first request are preserved in paging. You can exclude specific parameters using the "excludedParams" table attribute.