Posted By:
Brian_Glodde
Posted On:
Tuesday, November 26, 2002 12:06 PM
There are several ways to do this, none include javascript. And I might add this is not an easy technique to apply correctly. In most cases, this is done with a querystring (page.jsp?pg=1&psize=10) and one of the following techniques.
1.) If you're using a database such as mySQL, you can create a temp table via SQL statement. Explaining this technique would eat up the entire page, so instead check out this link that describes it nicely. This is an ASP example, but the same theories apply whether doing it in a stored proc or doing it with a straight SQL call and in whatever scripting language being used. This is also the fastest and most efficient way of pagination.
2.) When faced with a database that does not support the creation of temp tables (like Interbase/Firebird!), then another possible solution is to create vectors ( or arrays, whichever you like ) in your java code that hold the queried data, then you can loop around and send back only the data that is pertinent to the call (ie Page is 2, Amount of records is 10, so we would loop to element 11 push back elements 11 - 20). This data structure should be kept at the session level so requerying won't be necessary.
3.) Use an existing framework to get the job done. There are many taglibs out there that can most of this up for you.
ยป Jakarta Taglibs - Page 1.0
Hope that helps!