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

📄 exmaction.java

📁 用Struts+hibernate写的宠物医院
💻 JAVA
字号:
/*
 * Generated by MyEclipse Struts
 * Template path: templates/java/JavaClass.vtl
 */
package com.sean.pet.controller.action;

import java.sql.Date;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
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.sean.pet.controller.form.ExmForm;
import com.sean.pet.hibernate.po.Examination;
import com.sean.pet.model.service.ExaminationService;
import com.sean.pet.modelfactory.ModelFactory;

/** 
 * MyEclipse Struts
 * Creation date: 08-07-2008
 * 
 * XDoclet definition:
 * @struts.action path="/exm" name="exmForm" parameter="method" scope="request" validate="true"
 * @struts.action-forward name="exmEdit" path="/petstore/examination/examinationEdit.jsp"
 * @struts.action-forward name="exmAdd" path="/petstore/examination/examinationAdd.jsp"
 * @struts.action-forward name="exmList" path="/petstore/examination/examinationList.jsp"
 */
public class ExmAction extends DispatchAction {
	/*
	 * Generated Methods
	 */

	/** 
	 * Method execute
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 */
	
	private ExaminationService exmService;
	
	public ExmAction(){
		super();
		this.exmService = (ExaminationService)ModelFactory
				.getBean("com.sean.pet.model.service.impl.ExaminationServiceImpl");
	}
	
	public ActionForward toSave(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {

//		this.saveToken(request);
		return mapping.findForward("exmAdd");
	}

	public ActionForward save(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		// TODO Auto-generated method stub
		 
		ExmForm exmForm = (ExmForm) form;
//		if (this.isTokenValid(request)) {
//			resetToken(request);
		System.out.println("save------"+exmForm.getEmpid());
		System.out.println("save------"+exmForm.getDtime());
		Date dtime = Date.valueOf(exmForm.getTime());
		
//		java.text.DateFormat df = new java.text.SimpleDateFormat("yyyy-MM-dd");
		
		exmForm.setDtime(dtime);
		System.out.println("savepetid------"+exmForm.getPetid());
		System.out.println("savepetname------"+exmForm.getPet().getName());
		System.out.println("save++++++"+exmForm.getEmployee().getName());
		System.out.println("savedesc------"+exmForm.getEdesc());
			this.exmService.save(exmForm.valueOfUsers());
			return mapping.findForward("toShow");
//		} else {
//			saveToken(request);
//			System.out.println("重复提交");
//			return mapping.findForward("toShow");
//		}
	}

	public ActionForward delete(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {

		String id = request.getParameter("id");
		this.exmService.delete(id);
		return mapping.findForward("toShow");
	}

	@SuppressWarnings("unchecked")
	public ActionForward showList(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {

		List<Examination> list = this.exmService.findAll();
		request.setAttribute("allExm", list);
		return mapping.findForward("exmList");
	}

	public ActionForward toUpdate(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		// EmpForm empForm = (EmpForm) form;// TODO Auto-generated method stub
		String id = request.getParameter("id");
		// System.out.println("toUpdate--"+id);
		Examination exm = null;
		// if(emp != null){
		exm = this.exmService.findByID(id);
//		System.out.println("toUpdate+++"+pet.getPetowner().getId());
		// }
//		this.saveToken(request);
		request.setAttribute("exm", exm);
		return mapping.findForward("exmEdit");
	}

	public ActionForward update(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
//		if (isTokenValid(request)) {
//			resetToken(request);
			ExmForm exmForm = (ExmForm) form;
			Date dtime = Date.valueOf(exmForm.getTime());
			
//			java.text.DateFormat df = new java.text.SimpleDateFormat("yyyy-MM-dd");
			
			exmForm.setDtime(dtime);
			System.out.println("save------"+exmForm.getEmpid());
			System.out.println("savepetid------"+exmForm.getPetid());
			System.out.println("savepetname------"+exmForm.getPet().getName());
			System.out.println("save++++++"+exmForm.getEmployee().getName());
			System.out.println("savedesc------"+exmForm.getEdesc());
			this.exmService.update(exmForm.valueOfUsers());
			return mapping.findForward("toShow");
//		} else {
//			saveToken(request);
//			System.out.println("重复提交");
//			return mapping.findForward("toShow");
//		}
	}
}

⌨️ 快捷键说明

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