File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ResultSet Paging Help

 
david andre king
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a datasource with a list of information and need to implement a paging function, where for example, instead of showing all 1000 results, I want to display 25 or 50 per page..
I am considering using the Page-By-Page Iterator, but is there a way to do the same thing without using this pattern?
Thanks
 
Andres Gonzalez
Ranch Hand
Posts: 1561
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hhmm... I'm not too familiar with the Page-By-Page Iterator design pattern... but one idea that comes to my mind is to put the results in a vector and now you have control over the number of elements you want to display in every page. You can also control the >>next and <<back link.
it's only a suggestion... it's probably the same as page-by-page
cheers
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This question has been covered nicely in the Servlet, JSP and JDBC forums. I would recoomend a search in those forums first.
The short answer is that there are several possible solutions and the specific one you go with depends on your what you are doing.
Dave
 
lakshmi rajagopal
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
pass a parameter called page numer to the jsp page which is going to display result set.Restrict the no.of records per page like 25.now go to the record 25 * pagenumber and start to display upto 25 records. Put two buttons as previouse<< and next>> . In on click event handler of the previous button reduce the page number and call the same page. In on click event handler of the next button increase the page number and call the same page.
 
L Goundalkar
Ranch Hand
Posts: 395
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by lakshmi rajagopal:
pass a parameter called page numer to the jsp page which is going to display result set.Restrict the no.of records per page like 25.now go to the record 25 * pagenumber and start to display upto 25 records. Put two buttons as previouse<< and next>> . In on click event handler of the previous button reduce the page number and call the same page. In on click event handler of the next button increase the page number and call the same page.


Where will you have th ResultSet onject. ?
In Session??
Since you are passing the request to same JSP page. naturally you will not Query the database everytime.
Do you have any idea of using RowSet or CachedRowSet instead of this.
Thanks.
 
david andre king
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx for all the suggestions, I have a copy
of a good JSP book by Duane Field that refers to
a CachedRowSet Impl.
I want to retrieve a list of articles and populate an ArrayList or Vector.. (i made it that far), I just need to figure out the displaying of records.
For ex. if I have 100 records, I want to display
1-25, 26-50 ,etc..
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic