Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

"Next" button functionality

 
Katerina Karen
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a web application implemented im J2EE.On the screen I have a table wherein I display 5 records at a time.At the bottom of the table there is a "Next" button to fetch more records.So how is this "Next" button functionality implemented?Do I get all the records from the database put it in a cache and then keep iterating and keep showing 5 records on screen or everytime "Next" button is hit I go to the database and fetch the next 5 records?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34095
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try searching this forum for "paging." There are a bunch of good discussions explaining it.
 
Tim Hobbs
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use a mySQL DB which has LIMIT. I then pass a querystring "Records" value and grab (5 * Records). I know that is pretty vague, but I am sure you'll get the basic idea. If you don't use mySQL it really wouldn't work anyway
 
Andres Gonzalez
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've used the pager taglib to achieve that..
have a look at it
 
B Wask
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Katerina,
What you would want to do is retrieve all of your results from the database, and then store them in the HttpSession as a Collection of objects. Also store in the session an integer value indicating the number of items that have already been displayed (collections are zero-based, so showing five items would mean an index value of four). Each time the next button is pushed, retrieve the index value and display the next five items, incrementing the index appropriately. For example:

[ October 09, 2003: Message edited by: B Wask ]
 
Andres Gonzalez
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by B Wask:
Katerina,
What you would want to do is retrieve all of your results from the database, and then store them in the HttpSession as a Collection of objects. Also store in the session an integer value indicating the number of items that have already been displayed (collections are zero-based, so showing five items would mean an index value of four). Each time the next button is pushed, retrieve the index value and display the next five items, incrementing the index appropriately. For example:

[ October 09, 2003: Message edited by: B Wask ]

That's a valid solution. But why go into the trouble of creating that when you have a free taglib that you can use? you can select how many items you want to be displayed, etc...
reinventing the wheel in my opinion
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic