⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 outlineaction.java

📁 中应用程序的访问权限对Java Web Console 中应用程序的访问权限 成功登录 Web 控制台后,可能无法自动访问在该控制台中注册的所有应用程序。通常,必须安装应用程序,才能让所有的用户在控制
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/**
 * 
 */
package edu.yinhe.mis.control;

import java.io.IOException;
import java.io.PrintWriter;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Iterator;

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

import org.apache.commons.beanutils.BeanUtils;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import edu.yinhe.mis.dto.DictionaryDTO;
import edu.yinhe.mis.dto.OutlineDTO;
import edu.yinhe.mis.util.Filer;
import edu.yinhe.mis.vo.OutlineVO;
import edu.yinhe.system.common.AppException;
import edu.yinhe.system.control.BaseAction;
import edu.yinhe.system.util.PaginationVO;

/**
 * @author 陈忠
 * Creation date:04-30-2008 
 */
public class OutlineAction extends BaseAction {

	/**
	 * 为新增大纲提供转发
	 * @param mapping 响应转发请求
	 * @param form  OutlineForm对象
	 * @param request 请求响应
	 * @param response 响应结果
	 * @return forward 响应成功跳转到addoutline.jsp
	 * @author 陈忠
	 * Creation date:04-30-2008 
	 * @throws AppException 应用异常
	 */
	public ActionForward adds(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response){
		ActionForward forward=mapping.findForward("addoutline");
		return forward;	
	}


	/**
	 * 新增大纲信息
	 * @param mapping 响应转发请求
	 * @param form  OutlineForm对象
	 * @param request 请求响应
	 * @param response 响应结果
	 * @return forward 响应成功跳转到addsuccess.jsp
	 * @author 陈忠
	 * Creation date:04-30-2008 
	 * @throws AppException 应用异常
	 */
	public ActionForward add(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response){
		OutlineForm outlineForm=(OutlineForm) form;
		ActionForward forward=mapping.findForward("input");
		OutlineDTO outlineDTO =new OutlineDTO();
		boolean flag =false;

		try {
			BeanUtils.copyProperties(outlineDTO, outlineForm);
			outlineDTO.filer();
			service.setDataSource(this.getDataSource(request,"mydatasource"));
			flag=(Boolean)service.create(outlineDTO);

			if(flag){
				forward = mapping.findForward("addsuccess");
			}
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			e.printStackTrace();
		} catch (AppException e) {
			e.printStackTrace();
		}
		return forward;	
	}
	/**
	 * 查询大纲信息
	 * @param mapping 响应转发请求
	 * @param form  OutlineForm对象
	 * @param request 请求响应
	 * @param response 响应结果
	 * @return forward 响应成功,跳转到outlinelist.jsp
	 * @author 陈忠
	 * Creation date:04-30-2008 
	 * @throws AppException 应用异常
	 */
	public ActionForward query(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) throws AppException{
		OutlineForm outlineForm=(OutlineForm) form;
		ActionForward forward=mapping.findForward("input");
		OutlineDTO outlineDTO =new OutlineDTO();
		Object[] obj=null;
		ArrayList list=null;
		String currentPage=request.getParameter("currentPage");
		String type=request.getParameter("type");

		try {
			BeanUtils.copyProperties(outlineDTO, outlineForm);
			PaginationVO paginationVO = new PaginationVO();
			if(type==null||type.equals("")||type.equals("0")){
				currentPage="1";
			}else if(type.equals("1")){
				currentPage=String.valueOf(Integer.parseInt(outlineDTO.getCurrentPage())-1);
			}else if(type.equals("2")){
				currentPage=String.valueOf(Integer.parseInt(outlineDTO.getCurrentPage())+1);
			}else if(type.equals("3")){
				currentPage=(String)request.getParameter("allpage");
			}
			paginationVO.setCurrentPage(Integer.parseInt(currentPage));
			outlineDTO.setCurrentPage(String.valueOf(paginationVO.getCurrentPage()));
			outlineDTO.setRowPerPage("8");
			service.setDataSource(this.getDataSource(request,"mydatasource"));
			obj=(Object[]) service.findAll(outlineDTO);
			int count=((Integer)obj[0]).intValue();
			paginationVO.setResultsNumber(count);
			paginationVO.setRowsPerPage(8);
			paginationVO.setAllPages(count/paginationVO.getRowsPerPage()+(count%paginationVO.getRowsPerPage()>0?1:0));
			list=(ArrayList)obj[1];
			if(list.size()!=0&&list!=null){
				request.setAttribute("list", list);
				forward =mapping.findForward("queryoutline");
				request.setAttribute("outlineDTO", outlineDTO);
				request.setAttribute("paginationVO", paginationVO);
			}else{
				forward =mapping.findForward("failingQuery");
			}
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			e.printStackTrace();
		}

		return forward;	
	}

	/**
	 * 根据id删除大纲信息
	 * @param mapping 响应转发请求
	 * @param form  OutlineForm对象
	 * @param request 请求响应
	 * @param response 响应结果
	 * @return forward 响应成功跳转到query方法查询列表。
	 * @author 陈忠
	 * Creation date:04-30-2008 
	 */
	public ActionForward delete(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response){
		OutlineForm outlineForm=(OutlineForm) form;
		ActionForward forward=mapping.findForward("input");
		OutlineDTO outlineDTO =new OutlineDTO();
		boolean flag=false;
		String oid=request.getParameter("oid");
		Integer id=new Integer(0);
//		if(oid!=null){
//			id=new Integer(oid);
//		}else{
//			id=new Integer(0);
//		}
		
		try {
			BeanUtils.copyProperties(outlineDTO, outlineForm);
			outlineDTO.setId(id);
			service.setDataSource(this.getDataSource(request,"mydatasource"));
			service.remove(oid);
			flag=true;
			if(flag){
				forward =mapping.findForward("outlinelist");
			}
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			e.printStackTrace();
		} catch (AppException e) {
			e.printStackTrace();
		}
		return forward;	
	}

	/**
	 * 根据id查询大纲信息,供修改用
	 * @param mapping 响应转发请求
	 * @param form  OutlineForm对象
	 * @param request 请求响应
	 * @param response 响应结果
	 * @return forward 响应成功跳转到update方法
	 * @author 陈忠
	 * Creation date:04-30-2008 
	 */
	public ActionForward load(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response){
		OutlineForm outlineForm=(OutlineForm) form;
		ActionForward forward=mapping.findForward("input");
		OutlineDTO outlineDTO =new OutlineDTO();
		ArrayList list1=null;
		try {
			BeanUtils.copyProperties(outlineDTO, outlineForm);
			service.setDataSource(this.getDataSource(request,"mydatasource"));
			list1=(ArrayList) service.load(outlineDTO);
			if(list1.size()!=0&&list1!=null){
				request.setAttribute("list1",list1);
				forward = mapping.findForward("loadoutline");
			}
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			e.printStackTrace();
		} catch (AppException e) {
			e.printStackTrace();
		}
		return forward;	
	}

	
	/**
	 * 根据id查询大纲信息,供查看用
	 * @param mapping 响应转发请求
	 * @param form  OutlineForm对象
	 * @param request 请求响应
	 * @param response 响应结果
	 * @return forward 响应成功跳转到loadoutline.jsp
	 * @author 陈忠
	 * Creation date:04-30-2008 
	 */
	public ActionForward findById(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response){

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -