| Forums.Sureshkumar.net : A Perfect Place to Share Knowledge Blogs Games Magazines |
|
|
#1 (permalink) |
|
Junior Member
Join Date: Apr 2006
Location: India
Posts: 25
Thanks: 3 Thanked 1 Times in 1 Posts Thanks: 3
Thanked 1 Time in 1 Post
Rep Power: 3
|
Display database results across multiple pages..
Hi all,
I have database results in resultset object. I want to display it across multiple pages( say 10 results on a page) with the next and previous options and page number option as we see in google. what is the solution?? |
|
|
|
|
|
#2 (permalink) |
|
Moderator
Join Date: Apr 2006
Location: India
Posts: 636
Thanks: 57 Thanked 78 Times in 63 Posts Thanks: 57
Thanked 78 Times in 63 Posts
Rep Power: 17
|
Re: Display database results across multiple pages..
Hi Abhijeet, Assume that u have all the data in an
Arraylist, Each object representing a row in the table,Please try to understand the code and let me know your questions % ArrayList frmEmpList = new ArrayList(); if(session.getAttribute("frmEmpList")!=null) { frmEmpList = (ArrayList)session.getAttribute("frmEmpList"); } int noOfPages = 0; int remainder = 0; int noOfRequests = 0; if(frmEmpList!=null) { noOfRequests = frmEmpList.size(); remainder = frmEmpList.size()%10; noOfPages = frmEmpList.size()/10; if(remainder!=0) noOfPages = noOfPages + 1; } int currentPage = 1; String currentPageStr = request.getParameter("currentPage"); if(currentPageStr!=null) currentPage =Integer.parseInt(currentPageStr); % head script language="javascript" function getNextOrPrevDetails(url) { window.location.href = url; } /script /head --YOUR STATIC HEADINGS LIKE EMPNO,EMPNAME,EMPEMAIL DOJ ETC in column format-- % String empNo = " "; String empName = " "; String empEmail = " "; String doj = " "; int n=currentPage; int startPoint = 0; if(frmEmpList!=null && frmEmpList.size()>0) { if( (currentPage == n)&&(frmEmpList.size()==((n-1)*10))) { currentPage=(n-1); } if(currentPage!=1) startPoint = (currentPage-1)*10; if(((frmEmpList.size())-(startPoint))==0 ) { currentPage=currentPage-1; } EmployeeDetailsObject empObj = null; for (int i=startPoint,count=0;i empNo = empObj.getEmpno(); empName = empObj.getEname(); empEmail = empObj.getEmail(); doj = empObj.getDoj(); count ++; %> ---Place ur UR DYNAMIC CONTENT HERE in TR and TD ----- %} } % %if(currentPage!=1) {% Previous %} else {%> Previous %} if(noOfPages==0) currentPage=0; % | Page%=currentPage% of %=noOfPages% | % String pageno=String.valueOf(currentPage); session.setAttribute("PAGE",pageno); if(currentPage < noOfPages) {%> a href="javascript:getNextOrPrevDetails('employeeGrid.do?currentPage=%=(currentPage+1)%')">Next/a %} else { % Next %} % Where ever u find a % , it means it is a scriptlet in the JSP , replace the percentage with the scriptlet tag. Its a huge logic ,try to understand, pls let me know your questions Thank You
__________________
M0h@n |
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Database testing process in detail | au123 | Testing Tools & QA | 11 | 06-12-06 05:08 PM |
| PHP Book collection (online) | vjsreevs | PERL, PYTHON, PHP & MY SQL | 5 | 14-11-06 11:02 AM |
| INTERNET SESSION-3 (for newbies) | wizkid | NETWORK ADMINISTRATION , HARDWARE & TROUBLESHOOTING | 0 | 22-07-06 01:59 PM |
| INTERNET SESSION-2(for newbies) | wizkid | NETWORK ADMINISTRATION , HARDWARE & TROUBLESHOOTING | 0 | 21-07-06 03:22 PM |
| regarding oracle versions | Madhuri | ORACLE , SQL SERVER , SYBASE & Others | 7 | 07-07-06 07:06 PM |