Paging Techniques & Logics
Hii Javaities
I am developing an application where i need to have pagination as i am retreiving records from databse...............
I need to know wht are the pagination techniques.....
I have already gone through other threads bu i m not clear with tht.
I want 2 know which is the best pagination technique.....
1) querying databse again & again (restricting rows by using rownum , user will be asked to enter the number of records he wants to view & then this number will be used in SQL query to restrict the rows)
2) Retreiving Records at once & then storing them in Collection Objects..........
In case if using Collection is good , can ayone provide me with a little code to start with.
Plz Share ur views...................
Dear,
One of the best way is
1. give UniqueID for Records in database
2. On search get the uniqueIDs of Results( according to supplied Criteria)
3. Fix page size (u can use property file), Say 20
4. get the details of First 20 rec and display
5. on next or prev set the index and get another 20 rec
Ganesh
if resultset is huge then it is better to use 1st method using rownum.otherwise u can use 2nd method.nyways i've implemented 2nd one.
first u take resultset in a arraylist n get the size of that arraylist.define a variable page size with required size.devide size of arraylist by pagesize.
u'll get no of pages required.each time increase page no n get start row n end row.
set pageNumber 0 .on each click of next increment it by 1 upto (size-1).
startRow = pageNumber*PAGE_SIZE ;
endRow = startRow + PAGE_SIZE - 1 ;
iterate a loop from start row to end row n get the desired data.
snehaa at 2007-7-16 23:51:56 >
