Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Pagination Problem

 
vipul bondugula
Ranch Hand
Posts: 222
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I had 4000+ records. I already worked on a kind of pagination where for every page number, request hits the database. I want to
modify the design .

First i want store 300 records in arraylist from database. i will show 25 records for each page number. so for each page click, request will not hit the database. It fetches records from arraylist. If arraylist get scarce of records then another 300 records should be fetched and then displayed.

Any one having ideas or suggestions, Please share....:)


Thanks
Vipul Kumar
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65227
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like a simple matter of book-keeping to me. You just need to keep track of what you have on hand and what you have already shown.

Give the code a try and post with specific problems you are having with it.
 
vipul bondugula
Ranch Hand
Posts: 222
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear


This is my Action Class code.



This is PaginationUtil class which supports ....







My Dao class:


In Dao code there is duplicate code. I mean class loading and getting connection. After completing the whole thing then i will modify them. Please check the logic...

I am getting ArrayIndexOutOfBoundsException.




my JSP page




I used scriptlets in my jsp code. Please ignore it. Anyway i will change the code. I am more concentrating on the pagination . If pagination get succeed then i will change the scriptlet code.

For the first time list is iterating fine. after first 300 records pagination , i will fetch next 300 records from database. fetched records iam storing them in arraylist from index 0 to 299. I am calculating fromIndex and toIndex (i.e. sublist for pagination) based on pageNumber. based on page number fromIndex and toIndex values are some 290 to 318. But in the arraylist index is from 0 to 300.

This clearly states that my design is missing something. Please correct this and share your ideas to generalize it.

Thanks,
Vipul Kumar.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic