File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark ""Next" button functionality" Watch ""Next" button functionality" New topic
Author

"Next" button functionality

Katerina Karen
Greenhorn

Joined: Oct 06, 2003
Posts: 6
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 29240
    
139

Try searching this forum for "paging." There are a bunch of good discussions explaining it.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Tim Hobbs
Greenhorn

Joined: Oct 09, 2003
Posts: 12
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

Joined: Nov 27, 2001
Posts: 1561
I've used the pager taglib to achieve that..
have a look at it


I'm not going to be a Rock Star. I'm going to be a LEGEND! --Freddie Mercury
B Wask
Greenhorn

Joined: Oct 08, 2003
Posts: 5
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

Joined: Nov 27, 2001
Posts: 1561
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: "Next" button functionality
 
Similar Threads
iterating thru records
Pagination In struts with oracle database
Best practice to access large data from database
"Next" button functionality
iterating thru records