• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Next page Previous page

 
J Craig
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Given a result set or collection can anyone help in implementing a next page previous page functionality.
Should be able to list a set amount of records that will be viewed and if you get real fancy indicate how many pages are present basically the same as this site uses
 
Chris Baron
Ranch Hand
Posts: 1061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jay,
try LIMIT with your DB:

should return 5 rows: 11 to 15.

returns a rowcount of your table.
If you have a variable configuring the amount of listed items p. page
and one containing the actual pointer, e.g.

the next-link would be then:

and your SQL-Statement was something like this


...some untested hints to get started.
cb
 
Sloan Bowman
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As previously stated you can one of two things. First off the easiest would be to simply supply the offset option in your sql code and create a new Collection each time the page is loaded and pass that to the view. Or you can create a Collection and cache it to memory and only pull the specified number of objects from the Collection. If you need examples let me know.
 
michael yue
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some database does not support the LIMIT statement. How to tackle this? I come to know that db2 is one of db that does not support this. The closest thing to a LIMIT function is FETCH is db2. Maybe using FETCH with ORDER and WHERE will produce the results but i dont think its feasible.

Using caching I think will also eat up memory especially if the resultset is large in the region of thousands. So have to fully load up the thousands of records in to memory before finally displaying the first page.

Using cache rowset is also another way but i found out some webserver does not support this method such as Websphere.

So I was wondering is there a universal way to do this that can run on any webserver and database and on the same time does not take too much of a time to process.

Thanks
 
Brahim Bakayoko
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
see my post here: http://www.coderanch.com/t/284573/JSP/java/Displaying-large-ResultSet-multiple-HTML
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic