The first time I saw this question posted (in the thread referred to by rmg in his reply), I tried to think of a simple solution but couldn’t find one. Yesterday once again I was forced to think of this and despite my reluctance to lean towards java to get a solution, I had to do just that.
With the presumption that the results are retrieved from a database and re qurerying the database is too expensive, I wrote a couple of generic java services. The first one takes the the following inputs in form of a document:
- results (docList) of the db query,
- a page size (to be determined by the developer - denoting no. of results per page) and
- a query id - uniquely identifying this result.
The service stores the results (docList) in the session with key=queryID and returns only the first n (n = pageSize) results, along with the total number of possible pages (with the given pageSize).
The DSP plots these results as it ought to, stores the queryID as a hidden field and creates link for number of pages (ie 1 to total number of pages). Clicking on any of these links submits the request to the second java service and passes the queryID and the number of the page requested (depending on the pageNum link clicked). This service then proceeds to get retrieve the original results from the session (using the queryID) and does a few calculations to determine what set of results are to be returned.
I tried this approach and it works - however… I carried out this exercise just to see the feasibility and it may not be the right approach in your scenario. Storing results in session (esp if the result set is heavy) can be expensive. Guruz with greater experience may give pros n cons of this approach.