Auto-paging of long lists

120 items found, displaying 71 to 80.[First/Prev] 4, 5, 6, 7, 8, 9, 10, 11 [Next/Last]
ID Name Email Status
40496 Et Dolor et-dolor@tempor.com SEA
10062 Sed Labore sed-labore@sadipscing.com NONUMY
18775 At Sit At-sit@diam.com ELITR
328 Consetetur Eos consetetur-eos@sed.com SED
28365 Eirmod Ipsum eirmod-ipsum@sanctus.com MAGNA
42880 Tempor Vero tempor-vero@eirmod.com ET
2977 Est Eirmod est-eirmod@Stet.com SIT
96221 Stet Et Stet-et@labore.com REBUM
58864 Justo Lorem justo-Lorem@et.com LOREM
91221 Et No et-no@dolor.com ET

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.