• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Paging

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ??
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic