The application which we are working on currently communicates to an external third party web service. We have requirements where in we need to show paginated results in various screens (use cases). The web service will return 20 records in one call & in the return of first call results it will give us a unique identifier to fetch the next 20 records and so on. To accomodate this we have created a class called PaginateControl which comprises of a LinkedList (to store all the unique id's retrieved from web services) and flags previous and next. The webservice will traverse based on the unique id's and are not aware of our previous/next flags. So we will set the unique id in the web service call. As I said earlier the web service will generate a unique id on every invocation so when we do a previous it will generate a new id for the next batch. Hence we will have to keep modifying our linkedlist values to accomodate the call for the next batch. Also the web service has no standard way of saying end of resultset so when we get a duplicate id it is an indication of the last set.
I have managed to write this code but now I want to centralise all the logic inside the PaginateControl. Currently all the check for duplicate ids, setting of the boolean flags (previous & next) , modifying the linkedlist based on data fetched from the webservice is getting spilled over in my action classes. I have the PaginationControl as an instance variable in my action classes and use these boolean flags in jsp to show the previus & next links.
Now since pagination is required in a few more action classes we do not want to repeat this pagination handling logic in all of our actions and want to make it as modular as possible.
Do post your thoughts.
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop