Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Designing a pagination component

 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there,

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.


Regards,
MoHiT
 
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
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic