MeetroomAction.java
资源名称:(J2EE)oa.rar [点击查看]
上传用户:lm2018
上传日期:2015-12-12
资源大小:30449k
文件大小:7k
源码类别:
Jsp/Servlet
开发平台:
Java
- //Created by MyEclipse Struts
- // XSL source (default): platform:/plugin/com.genuitec.eclipse.cross.easystruts.eclipse_4.1.0/xslt/JavaClass.xsl
- package com.oa.module.meet.struts.action;
- import java.io.IOException;
- import java.io.PrintWriter;
- import java.lang.reflect.InvocationTargetException;
- import java.util.List;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import org.apache.commons.beanutils.BeanUtils;
- import org.apache.struts.action.ActionErrors;
- import org.apache.struts.action.ActionForm;
- import org.apache.struts.action.ActionForward;
- import org.apache.struts.action.ActionMapping;
- import org.apache.struts.action.ActionMessage;
- import org.apache.struts.actions.DispatchAction;
- import com.oa.module.meet.hibernate.Tmeetroom;
- import com.oa.module.meet.meetroomdao.MeetRoomInterfer;
- import com.oa.module.meet.struts.form.MeetroomForm;
- import com.oa.module.pub.ectomere.XPage;
- /**
- * MyEclipse Struts Creation date: 01-19-2008
- *
- * XDoclet definition:
- *
- * @struts.action path="/meetroom" name="meetroomForm" parameter="task"
- * scope="request" validate="true"
- */
- public class MeetroomAction extends DispatchAction {
- // --------------------------------------------------------- Instance
- // Variables
- private MeetRoomInterfer meetroominter;
- // --------------------------------------------------------- Methods
- /**
- * Method execute
- *
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return ActionForward
- */
- public ActionForward query(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response) {
- MeetroomForm meetroomForm = (MeetroomForm) form;
- int currentPage = 1;
- try {
- currentPage = Integer.parseInt(request.getParameter("currentPage"));
- } catch (Exception e) {
- currentPage = 1;
- }
- int count = 5;
- Tmeetroom info = new Tmeetroom();
- // 拷贝查询参数
- try {
- BeanUtils.copyProperties(info, meetroomForm);
- } catch (IllegalAccessException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (InvocationTargetException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- XPage meetroompage = meetroominter.getItemlist(currentPage, count, info);
- request.setAttribute("meetroomtpage", meetroompage);
- return mapping.findForward("roomlist");
- }
- public ActionForward addlist(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response) {
- MeetroomForm meetroomForm = (MeetroomForm) form;
- List addrlist = meetroominter.addrlist();
- request.setAttribute("addrlist",addrlist);
- meetroomForm.setTask("add");
- return mapping.getInputForward();
- }
- public ActionForward add(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response) {
- MeetroomForm meetroomForm = (MeetroomForm) form;
- Tmeetroom room = new Tmeetroom();
- try {
- BeanUtils.copyProperties(room,meetroomForm);
- } catch (IllegalAccessException e) {
- // TODO 自动生成 catch 块
- e.printStackTrace();
- } catch (InvocationTargetException e) {
- // TODO 自动生成 catch 块
- e.printStackTrace();
- }
- boolean flag = meetroominter.great(room);
- if (flag) {
- request.setAttribute("msg", "添加成功");
- return new ActionForward("/meetroom.do?task=query", true);
- } else {
- request.setAttribute("msg", "添加失败");
- return mapping.getInputForward();
- }
- }
- public ActionForward init(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response) {
- MeetroomForm meetroomForm = (MeetroomForm) form;
- Tmeetroom room = meetroominter.getlistroom(meetroomForm.getRmid());
- try {
- BeanUtils.copyProperties(meetroomForm,room);
- } catch (IllegalAccessException e) {
- // TODO 自动生成 catch 块
- e.printStackTrace();
- } catch (InvocationTargetException e) {
- // TODO 自动生成 catch 块
- e.printStackTrace();
- }
- List addrlist = meetroominter.addrlist();
- request.setAttribute("addrlist",addrlist);
- meetroomForm.setTask("edit");
- return mapping.getInputForward();
- }
- public ActionForward edit(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response) {
- MeetroomForm meetroomForm = (MeetroomForm) form;
- Tmeetroom room = new Tmeetroom();
- try {
- BeanUtils.copyProperties(room,meetroomForm);
- } catch (IllegalAccessException e) {
- // TODO 自动生成 catch 块
- e.printStackTrace();
- } catch (InvocationTargetException e) {
- // TODO 自动生成 catch 块
- e.printStackTrace();
- }
- boolean flag = meetroominter.update(room);
- if (flag) {
- request.setAttribute("msg", "修改成功");
- return new ActionForward("/meetroom.do?task=query", true);
- } else {
- request.setAttribute("msg", "修改失败");
- return mapping.getInputForward();
- }
- }
- /**
- * 冻结会议室
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- */
- public ActionForward support(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response) {
- MeetroomForm meetroomForm = (MeetroomForm) form;
- meetroomForm.setRstate(2);
- Tmeetroom room = new Tmeetroom();
- room.setRmid(meetroomForm.getRmid());
- room.setRaddress(meetroomForm.getRaddress());
- room.setRmemo(meetroomForm.getRmemo());
- room.setRname(meetroomForm.getRname());
- room.setRnumber(meetroomForm.getRnumber());
- try {
- BeanUtils.copyProperties(room,meetroomForm);
- } catch (IllegalAccessException e) {
- // TODO 自动生成 catch 块
- e.printStackTrace();
- } catch (InvocationTargetException e) {
- // TODO 自动生成 catch 块
- e.printStackTrace();
- }
- boolean flag = meetroominter.updatestats(room);
- if (flag) {
- request.setAttribute("msg", "冻结成功");
- return new ActionForward("/meetroom.do?task=query", true);
- } else {
- return null;
- }
- }
- /**
- * 激活会议室
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- */
- public ActionForward life(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response) {
- MeetroomForm meetroomForm = (MeetroomForm) form;
- meetroomForm.setRstate(0);
- Tmeetroom room = new Tmeetroom();
- room.setRmid(meetroomForm.getRmid());
- boolean flag = meetroominter.updatestats2(room);
- if (flag) {
- request.setAttribute("msg", "激活成功");
- return new ActionForward("/meetroom.do?task=query", true);
- } else {
- return null;
- }
- }
- public ActionForward checkname(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response) {
- MeetroomForm meetroomForm = (MeetroomForm) form;
- String name = request.getParameter("name");
- PrintWriter out=null;
- try {
- out=response.getWriter();
- } catch (IOException e) {
- e.printStackTrace();
- }
- boolean flag=meetroominter.selectname(name);
- if(flag){
- out.print("这个会议名称已存在...");
- }
- return null;
- }
- public MeetRoomInterfer getMeetroominter() {
- return meetroominter;
- }
- public void setMeetroominter(MeetRoomInterfer meetroominter) {
- this.meetroominter = meetroominter;
- }
- }