Forums.Sureshkumar.net : A Perfect Place to Share Knowledge         Blogs     Games    Magazines    

"Sharing knowledge does not lessen your store, often it gets you more. Sharing plays a key role in relationships and bonding, happens in small steps and is assisted through community membership."

Go Back   SURESHKUMAR.NET FORUMS > TECHNICAL DISCUSSIONS > JAVA Technologies
Register FAQ Members List Calendar Games Blogs Search Today's Posts Mark Forums Read

   

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
Old 08-12-06, 04:53 PM   #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 abhijeet_pcl has disabled reputation
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??
abhijeet_pcl is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 11-12-06, 11:36 AM   #2 (permalink)
Moderator
 
t_mohan's Avatar
 
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 t_mohan is a splendid one to behold t_mohan is a splendid one to behold t_mohan is a splendid one to behold t_mohan is a splendid one to behold t_mohan is a splendid one to behold t_mohan is a splendid one to behold t_mohan is a splendid one to behold
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 = "&nbsp";
String empName = "&nbsp";
String empEmail = "&nbsp";
String doj = "&nbsp";
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 empObj = (EmployeeDetailsObject)frmEmpList.get(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
t_mohan is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On

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


All times are GMT +6.5. The time now is 02:23 AM.





Search Engine Optimization by vBSEO 3.1.0