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

📄 deptaction.java

📁 负责公文的传输及一些处理功能
💻 JAVA
字号:
//Created by MyEclipse Struts
// XSL source (default): platform:/plugin/com.genuitec.eclipse.cross.easystruts.eclipse_4.1.1/xslt/JavaClass.xsl

package com.example.web.action;

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

import org.apache.commons.beanutils.BeanUtils;
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 org.apache.struts.actions.DispatchAction;

import com.example.businessmodel.Page;
import com.example.businessmodel.PageForm;
import com.example.gw.unit.IUnitManager;
import com.example.gw.unit.Unit;
import com.example.web.actionform.DeptForm;
import com.example.gw.system.user.UserInfo;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.io.XMLWriter;
import java.io.*;
import java.util.List;
import java.lang.reflect.Method;
/** 
 * MyEclipse Struts
 * Creation date: 01-23-2007
 * 
 * XDoclet definition:
 * @struts.action validate="true"
 */
public class DeptAction extends DispatchAction{

	private IUnitManager unitManager;
	public void setUnitManager(IUnitManager unitManager){
		this.unitManager = unitManager;
	}
	public IUnitManager getUnitManager(){
		return unitManager;
	}
	// --------------------------------------------------------- Instance Variables

	// --------------------------------------------------------- Methods

	public ActionForward deptList(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		PageForm pageForm = (PageForm) form;
		int start = 1;
		String unitId = "";
		if (pageForm != null) {
			start = pageForm.getStart();
		} else {
			if (request.getParameter("start") != null
					&& !(request.getParameter("start").equals(""))) {
				start = Integer.parseInt(request.getParameter("start"));
			}
		}
		UserInfo userinfo = (UserInfo) request.getSession().getAttribute(
				"userinfo");
		unitId = userinfo.getUnit().getUnitId().toString();
		try {
			Page page = unitManager.getDepartList(unitId, start, 15);
			request.setAttribute("page", page);
		} catch (Exception e) {
			e.printStackTrace();
		}
		// TODO Auto-generated method stub
		return mapping.findForward("deptList");
	}

	public ActionForward saveDept(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		DeptForm deptForm = (DeptForm) form;
		String unitId = request.getParameter("userUnitId");
		Unit dept = new Unit();
		try {
			BeanUtils.copyProperties(dept, deptForm);
			unitManager.saveUnit(dept);
		} catch (Exception e) {
			e.printStackTrace();
			request.setAttribute("dept",dept);
			//System.out.println("e.getMessage()="+e.getMessage());
			request.setAttribute("exception",e.getMessage());
			return mapping.findForward("editDept");
		}
		return mapping.findForward("callDeptList");
	}

	public ActionForward deleteDept(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		String unitId = request.getParameter("deptId");
		try {
			Unit dept = unitManager.findUnit(unitId);
			String str = unitManager.delDept(dept);
			if(str != null){
				request.setAttribute("showMessage",str);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return mapping.findForward("callDeptList");
	}

	public ActionForward editDept(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		String deptId = request.getParameter("deptId");
		try {
			if (!("".equals(deptId))) {
				Unit dept = (Unit) unitManager
						.getUnit(Integer.parseInt(deptId));
				request.setAttribute("dept", dept);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		if(request.getParameter("viewStatus")!=null && request.getParameter("viewStatus").equals("1")){
			return mapping.findForward("viewDept");
		}
		return mapping.findForward("editDept");
	}

}

⌨️ 快捷键说明

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