• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Paging

 
novemberborn
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can we do paging of result retrieved from database (i.e only ten results should be shown on first page another ten on next page and so on). If yes then how ??
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a fairly standard question. There are several possible answers which depend on how much data you have to display, and where it comes from.
If you have a relatively small amount of data, which you can get before you display any pages, you can put it in an array (or an ArrayList, or Vector or other indexable data structure) and put that in the session with some indication of what you have displayed already. Each new page request can then show the next page of the data.
If you don't know how much data you have, or it is "expensive" to get it all at once, you really have to go back to the source for each new page. If your data is stored in a database, then you can generate slightly different SQL for each page to retrieve only the items you are interested in - the exact details depend on how your data is stored, of course.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic