I have to implement a pagination concept, where a page shows only a limited subset (say, 10 Items) at a time, and users can navigate to the next and previous pages manually.
This code produces 1st 20 records. But what about navigation to another page, where next set of 20 records are displayed?
Can Hibernate alone solve this problem, without going into other libraries like Display tag libraries & Jsp taglib?
Thanks Hemant Thard. It fetches me required number of records in a jsp page. But how to navigate to another page where it will fetch me another set of records. Should i run the servlet & Dao class again?
Thanks Bear Bibeault.
I have fetched all the 30records, but i need to display them 5 at a page, each record with 2 radio buttons.
Should i call servlet & dao class again,but that will be a lot of db hits? Or should i have a link in jsp page invoking the dao code with next page number appended to the url?
Or should i invoke the dao code from jsp with page number incremented by 1? No i guess that's a bad idea
Or, put the code which are in scriplet into a servlet, and call it each time . But, will that be efficient, if need to go for 70Records, 5 at a time, that too with 2 radio buttons, for getting user choice?
All you need to do is keep track of which page number you want to look at, and do a little math to figure out what the value to pass to setFirstResult().