/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.j2ee.struts.action;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
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.j2ee.domain.Classes;
import com.j2ee.manager.ClassesManager;
import com.j2ee.struts.form.ClassesForm;
import com.sun.org.apache.commons.beanutils.BeanUtils;
/**
* MyEclipse Struts
* Creation date: 06-08-2011
*
* XDoclet definition:
* @struts.action path="/classes" name="classesForm" input="/index.jsp" scope="request" validate="true"
*/
public class ClassesAction extends DispatchAction {
/*
* Generated Methods
*/
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)throws Exception {
ClassesForm classesForm = (ClassesForm) form;// TODO Auto-generated method stub
return super.execute(mapping, classesForm, request, response);
}
public ActionForward add(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws IllegalAccessException, InvocationTargetException {
ClassesForm classesForm = (ClassesForm) form;// TODO Auto-generated method stub
Classes classes = new Classes();
BeanUtils.copyProperties(classes, classesForm);
ClassesManager.getInstance().add(classes);
return mapping.findForward("addclasssuccuss");
}
public ActionForward deleteByClassNum(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws IllegalAccessException, InvocationTargetException {
ClassesForm classesForm = (ClassesForm) form;// TODO Auto-generated method stub
Classes classes = new Classes();
BeanUtils.copyProperties(classes, classesForm);
ClassesManager.getInstance().deleteByClassNum(classes.getClassNum());
return mapping.findForward("deletesuccess");
}
public ActionForward deleteById(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws IllegalAccessException, InvocationTargetException {
ClassesForm classesForm = (ClassesForm) form;// TODO Auto-generated method stub
Classes classes = new Classes();
BeanUtils.copyProperties(classes, classesForm);
ClassesManager.getInstance().deleteById(Integer.parseInt(request.getParameter("id")));
return mapping.findForward("deletesuccess");
}
public ActionForward readAllClass(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws IllegalAccessException, InvocationTargetException {
ClassesForm classesForm = (ClassesForm) form;// TODO Auto-generated method stub
List<Classes> list = new ArrayList<Classes>();
list = ClassesManager.getInstance().readAllClass();
request.setAttribute("lists", list);
return mapping.findForward("readallclass");
}
public ActionForward readOneClass(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws IllegalAccessException, InvocationTargetException {
ClassesForm classesForm = (ClassesForm) form;// TODO Auto-generated method stub
Classes classes = new Classes();
BeanUtils.copyProperties(classes, classesForm);
classes = ClassesManager.getInstance().readOneClassByNum(classes.getClassNum());
request.setAttribute("classes", classes);
return mapping.findForward("searchresult");
}
public ActionForward modify(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws IllegalAccessException, InvocationTargetException {
ClassesForm classesForm = (ClassesForm) form;// TODO Auto-generated method stub
String id = request.getParameter("id");
String description = request.getParameter("description");
ClassesManager.getInstance().modifyClassInfo(Integer.parseInt(id), description);
return mapping.findForward("modifysuccess");
}
public ActionForward modifyClassInfo(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws IllegalAccessException, InvocationTargetException {
ClassesForm classesForm = (ClassesForm) form;// TODO Auto-generated method stub
String id = request.getParameter("id");
String time = request.getParameter("time");
String description = request.getParameter("description");
Classes classes = ClassesManager.getInstance().readOneClass(Integer.parseInt(id));
request.setAttribute("classes", classes);
request.setAttribute("time", time);
request.setAttribute("description", description);
return mapping.findForward("modifyclassinfo");
}
public ActionForward search(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws IllegalAccessException, InvocationTargetException {
ClassesForm classesForm = (ClassesForm) form;// TODO Auto-generated method stub
String num = request.getParameter("classNum");
Classes classes = new Classes();
classes = ClassesManager.getInstance().readOneClassByNum(Integer.parseInt(num));
request.setAttribute("classes", classes);
return mapping.findForward("searchresult");
}
}
评论7
最新资源