File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Pagination Framework/libraries Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Pagination Framework/libraries" Watch "Pagination Framework/libraries" New topic
Author

Pagination Framework/libraries

Pallav Bora
Ranch Hand

Joined: Oct 13, 2009
Posts: 73
My application is struts 1.38 application.

We have a pagination requirements. What would be a best pagination library? We would like to avoid storing huge collection in memory.

Thanks
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
DisplayTag comes to mind.
Claudiu Chelemen
Ranch Hand

Joined: Mar 25, 2011
Posts: 71

I've also used the pager plugin on the jquery-based tablesorter, it's quick and simple.

http://tablesorter.com/docs/
http://tablesorter.com/docs/example-pager.html

Cheers,
Claudiu
sreejith sreedharan
Greenhorn

Joined: Sep 06, 2010
Posts: 5
best option is to create a custom pagination , with offset limit star , end in the sql query .

common method .

1 . getTotalRecord count
2 . get the page number
3 . get the start , rowlimit
4 . create sql query based on this . with offset cluase
5. show data
Shankar Tanikella
Ranch Hand

Joined: Jan 30, 2011
Posts: 329

Hi,
Just to share my opinion, given the problem statement, i would ask myself several questions like

What are the records that I am paginating? Are they simple records(1 or 2 columns from DB) or some table of data with several number of columns?
Is the data listing being paginated is static or dynamic?
If it is a table with several columns then how is the database designed? Is it normalized? If it is properly normalized, at an average how many tables i join to fetch the listing?
Is my application rich in GUI?
How many listings do i have to paginate?

The reasons for these questions being that, when any application is under development or initial phases of production it would be happy day scenario. As the software evolves and the user base increases the data increases. Say, if the DB is very well normalised and to fetch a listing i have to hit some 5-10 tables and day-day the data kept on increasing. Very quickly we have look in terms of performance.
Good libraries like "DisplayTag/TableSorter" is very easy to plugin and effective but (it paginates at UI level) when the day comes that you do not want to fetch all the records from DB instead you would only want just 30 records which you display in UI? Then we end up opening the opensource. We tend to do all the pagination and sorting stuff at query level.
If the number of listings that are being paginated are few, then i would go for a library like DisplayTag.
If application UI is rich (normally might not be in this case as struts 1.3 is chosen) i would go for somthing like TableSorter due to the look and feel (again i would consider the performance)

Finally if the problem statement/requirement is as minor as pagination, I would implement it based on the application needs. I would still prefer see how these DisplayTag and TableSort are implemented and make sure i get the best out of it and also make sure that i do not missout or make silly mistakes while implementing the custom solution since sometimes it gets tricky while implementing the "Page Jump" & and other types of navigations along with sorting.
However, it would be a matter of coding some 5-10 simple java files after initial analysis and design. Which sould not take much time.

Bottomline - I agree with Sreejith


Have Fun with Java
little,little.. little by little makes a lot..
Sunil Sunny
Ranch Hand

Joined: Oct 18, 2011
Posts: 41
you can use Dispaly tag libraray http://displaytag.sourceforge.net/11/tut_externalSortAndPage.html
Pallav Bora
Ranch Hand

Joined: Oct 13, 2009
Posts: 73
Thanks everybody for your responses !
Shankar Tanikella
Ranch Hand

Joined: Jan 30, 2011
Posts: 329

Hi Pallav, 'pagination' not a big solution, share your final decision with reasons if possible (just curiosity) to close the post (might be useful for someone else). Let it be how silly or genuine it might be, it's ok.
 
 
subject: Pagination Framework/libraries