/*
 * Generated by MyEclipse Struts
 * Template path: templates/java/JavaClass.vtl
 */
package com.yuntong.action;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

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;

import com.yuntong.business.vo.G_DriverInfoVO;
import com.yuntong.business.vo.G_TruckInfoVO;
import com.yuntong.service.G_IDriverInfoService;

/** 
 * MyEclipse Struts
 * Creation date: 04-12-2007
 * 
 * XDoclet definition:
 * @struts.action validate="true"
 */
public class G_FindAllDriverInfoAction extends Action {
	private int pageSize;
	private G_IDriverInfoService driverInfoService;
	/*
	 * Generated Methods
	 */

	/** 
	 * Method execute
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws IOException 
	 */
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) throws IOException {
		response.setContentType("text/xml; charset=UTF-8");
		PrintWriter out = response.getWriter();
		String page=request.getParameter("curPage");
		int curPage=0;
		if(page.equals("") || page==null || page.equals("0")){
			curPage=1;
		}else{
			curPage=Integer.parseInt(page);
		}
		System.out.println("**************************"+curPage);
		List list=driverInfoService.getAllDriverInfo(pageSize, curPage);
		System.out.println("list"+list.size());
		int totalPage=driverInfoService.getTotalPage(pageSize);
		out.print("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
		out.print("<info>");
		for (int i = 0; i < list.size(); i++) {
			G_DriverInfoVO vo=(G_DriverInfoVO) list.get(i);
			out.print("<driverNaneList value='"+vo.getDriverName()+"'>");
			out.print(vo.getDriverName());
			out.print("</driverNaneList>");
		}
	
		
		out.print("<page>");
		out.print("<totalPage value='"+totalPage+"'>");
		out.print(totalPage);
		out.print("</totalPage>");
		out.print("</page>");
		out.print("</info>");
		out.close();
		return null;
	}

	public G_IDriverInfoService getDriverInfoService() {
		return driverInfoService;
	}

	public void setDriverInfoService(G_IDriverInfoService driverInfoService) {
		this.driverInfoService = driverInfoService;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
}