Pagination Please help needed urgent

Hello all, Please help me out how to use pagination. i have no idea wh

Page 1 of 1

2 Replies - 1879 Views - Last Post: 05 September 2006 - 11:22 AM Rate Topic: -----

#1 csat  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 3
  • Joined: 01-September 06

Pagination Please help needed urgent

Posted 05 September 2006 - 11:12 AM

JSP Code
<%@ page language="java" contentType="text/html" %>

<%@page import="java.util.*"%>
<%@ include file="Header-Mgr.jsp" %>


<!-- Mgr_editinfo.jsp -->

<head><center><ul><h1><u> LIST OF CUSTOMERS </u></h1></ul></head>

<form name="customer_info" method="post" action="<%=request.getContextPath()%>/pages/Mgr_Welcome.jsp" >

<table border = '1' cellspacing = '5' cellpadding = '3'>
	<tr>
		<th>S.No</th>
		<th>Name</th>
		<th>Company</th>
		<th>Contact</th>
		<th>Email</th>
		<th>Phone</th>
		<th>City</th>
		<th>State</th>
		<th>Beta Program</th>
	</tr>
	


<% if(request.getAttribute("MGR_CUSTOMER")!=null)


	{
		ArrayList tempList = (ArrayList)request.getAttribute("MGR_CUSTOMER");
		ArrayList tempBadCust = (ArrayList)request.getAttribute("ALL_BADBETA");
		
		for(int i=0;i<tempList.size();i++)
		{
			MgrCustomer mgrCust = (MgrCustomer)tempList.get(i);
			String bgColor = "#000000";
			if(mgrCust.getCompany() != null)
			{
				if(tempBadCust.contains(mgrCust.getCompany()))
				{
					bgColor = "#FF0000";
				}
			}
			
%>


	
	<tr >
		<td><font color="<%=bgColor%>"><%=i+1%></font></td>

		<td><font color="<%=bgColor%>"><%=mgrCust.getName()%></font></td>
		<td><font color="<%=bgColor%>"><%=mgrCust.getCompany()%></font></td>
		<td><font color="<%=bgColor%>"><%=mgrCust.getContact()%></font></td>
		<td><font color="<%=bgColor%>"><%=mgrCust.getEmail()%></font></td>
		<td><font color="<%=bgColor%>"><%=mgrCust.getPhone()%></font></td>
		<td><font color="<%=bgColor%>"><%=mgrCust.getCity()%></font></td>
		<td><font color="<%=bgColor%>"><%=mgrCust.getState()%></font></td>
		<td><font color="<%=bgColor%>"><%=mgrCust.getProg()%></font></td>
		
	
	</tr>

<%}
}%>

</center>
</table>


	<tr>
		  <td> &nbsp;</td>	
		  <td colspan=2><input type="button" value="<<Prev>>" onclick="doPrev()"></td>
		  <td colspan=2><input type="submit" value="OK"></td>
		  <td colspan=2><input type="button" value="<<Next>>" onclick="doNext()"></td>
	</tr>
	
</form>	

<script language="javascript">

function doNext()
{
	
	
	document.customer_info.action="Mgr_editCustomer.do?userid=<%=request.getParameter("userid")%>";
	document.customer_info.submit();
}


</script>
<%@ include file="Footer.jsp" %>




Java Code

package com.vmware.mgr.actions;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;


public class MgrEditAction extends Action{
	
		
	private String selectinfo = "select p.name,p.company,p.contact,p.email,p.phone,p.city, p.state, r.program from vm_beta_users p, vm_beta_programs r, vm_beta_user_programs q where q.user_id=p.id and q.program_id=r.id";
	private String selectAllBadBetaCust = "select * from vm_badbeta_users";
	
	public ActionForward execute(ActionMapping mapping,
			ActionForm form,
			HttpServletRequest request,
			HttpServletResponse response)
	
	throws Exception
	{
		System.out.println("MgrEditAction.execute()");				
		
		
		DatabaseService ds = DatabaseService.getInstance();
		boolean exists;
		ResultSet rs = null;
		PreparedStatement ps = null;
		Connection conn = null;
		MgrCustomer mgrCust = null;
		ArrayList custList = new ArrayList();
		
		String offSetString = (String) request.getSession().getAttribute("offSet");
		int offSet = 0;
		if (offSetString != null)
		{
			offSet = Integer.parseInt(offSetString);
		}
		
		String lastIndexString = (String) request.getSession().getAttribute("offSet");
		
		try
		{
			conn = ds.getConnection();
			ps = ds.getPreparedStatement(selectinfo, conn);
			exists = false;
			rs = ds.getResultSetFromPreparedStatement(ps);			
			System.out.println("offSet :"+offSet);
			System.out.println("current row:"+rs.getRow());
			
			
			
			int index = 1;
	
			while(rs.next())
			{
				if(index++ < offSet)
				{
					continue;
				}
				
				
				mgrCust = new MgrCustomer();
				
				System.out.println("Got user:"+rs.getString(1));
				mgrCust.setName(rs.getString(1));
				
				System.out.println("Got user:"+rs.getString(2));
				mgrCust.setCompany(rs.getString(2));
				
				System.out.println("Got user:"+rs.getString(3));
				mgrCust.setContact(rs.getString(3));
				
				System.out.println("Got user:"+rs.getString(4));
				mgrCust.setEmail(rs.getString(4));
				
				System.out.println("Got user:"+rs.getString(5));
				mgrCust.setPhone(rs.getString(5));
				
				System.out.println("Got user:"+rs.getString(6));
				mgrCust.setCity(rs.getString(6));
				
				System.out.println("Got user:"+rs.getString(7));
				mgrCust.setState(rs.getString(7));
				
				System.out.println("Got User:"+rs.getString(8));
				mgrCust.setProg(rs.getString(8));
				
				custList.add(mgrCust);
				exists = true;
				
				if (custList.size() >= 20)
					break;
				

				int lastIndex = offSet;
				if (lastIndexString != null)
				{
					lastIndex = Integer.parseInt(lastIndexString);
				}	
				
				System.out.println("LastIndex:" +lastIndex);
				
				if(lastIndex-- > offSet)
				{
					break;
				}
							
			}

			
			
			
			rs.close();
			ps.close();
			
			request.getSession().setAttribute("offSet", String.valueOf(offSet + custList.size()));
			
			
			
			ps=ds.getPreparedStatement(selectAllBadBetaCust, conn);
			rs=ds.getResultSetFromPreparedStatement(ps);
			ArrayList badCust = new ArrayList();
			
			while(rs.next())
			{
				badCust.add(rs.getString(2));				
			}
			
			request.setAttribute("ALL_BADBETA",badCust);
		}
		finally 
		{
			ds.release(rs, ps, conn);
		}

			
		ActionForward af = mapping.findForward("success");
		request.setAttribute("MGR_CUSTOMER",custList);
		System.out.println("AF " + af.getPath());
		return af;
		
	}
}



edit: added [code] tags

This post has been edited by jayman9: 05 September 2006 - 11:19 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Pagination Please help needed urgent

#2 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Pagination Please help needed urgent

Posted 05 September 2006 - 11:15 AM

Can you specify the problem you have encountered? there are some links to pagination methods listed here as well:
http://forums.dreami...wtopic18278.htm
Was This Post Helpful? 0
  • +
  • -

#3 csat  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 3
  • Joined: 01-September 06

Re: Pagination Please help needed urgent

Posted 05 September 2006 - 11:22 AM

View PostAmadeus, on 5 Sep, 2006 - 11:15 AM, said:

Can you specify the problem you have encountered? there are some links to pagination methods listed here as well:
http://forums.dreami...wtopic18278.htm



Hello,

I am able to get the records from db. i would like to display the records using pagination and i have read many articles but not to able to understand where to included all the pagination tags etc etc. i am having diff in understandin it. please help me out
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1