/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.zhen.web.action;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
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.zhen.service.EmployeeService;
import com.zhen.service.impl.EmployeeServiceImpl;
import com.zhen.util.ArrayUtil;
import com.zhen.util.DateUtil;
import com.zhen.vo.Employee;
import com.zhen.vo.PageBean;
import com.zhen.web.form.EmployeeForm;
/**
* MyEclipse Struts
* Creation date: 04-18-2011
*
* XDoclet definition:
* @struts.action parameter="operator"
* @struts.action-forward name="show" path="/employee.jsp"
*/
public class EmployeeAction extends DispatchAction {
/*
* Generated Methods
*/
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
private EmployeeService employeeService=new EmployeeServiceImpl();
public ActionForward showAll(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
request.setAttribute("empList", employeeService.findAllEmployee());
return mapping.findForward("show");
}
public ActionForward pagenation(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
EmployeeForm empForm=(EmployeeForm) form;
PageBean<Employee> pb=empForm.getPageBean();
pb.setIndex(empForm.getPageBean().getIndex());
request.setAttribute("pb", employeeService.pagenation(pb));
return mapping.findForward("show");
}
public ActionForward delete(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
EmployeeForm empForm=(EmployeeForm) form;
employeeService.delete(empForm.getEmployee().getEmpID());
return mapping.findForward("page");
}
public ActionForward update(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
EmployeeForm empForm= (EmployeeForm) form;
Employee emp=empForm.getEmployee();
employeeService.update(emp.getEmpID(), emp);
return mapping.findForward("page");
}
public ActionForward setDept(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
EmployeeForm empForm= (EmployeeForm) form;
Employee emp=empForm.getEmployee();
employeeService.setDept(emp.getEmpID(), emp.getDeptID());
return mapping.findForward("page");
}
public ActionForward getEmployee(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
EmployeeForm empForm= (EmployeeForm) form;
Employee emp=employeeService.findById(empForm.getEmployee().getEmpID());
// System.out.println(emp.getEmpID()+"-"+emp.getEmpName()+"-"+emp.getEmpBirthday()+"-"+emp.getFavourite()+"-"+emp.getDeptName());
empForm.setEmployee(emp);
String tag=request.getParameter("temp");
if("edit".equals(tag)){
return mapping.findForward("edit");
}else if("dept".equals(tag)){
return mapping.findForward("change");
}else if("detail".equals(tag)){
return mapping.findForward("detail");
}
return null;
}
public ActionForward save(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
EmployeeForm empForm= (EmployeeForm) form;
Employee emp=empForm.getEmployee();
employeeService.save(emp);
return mapping.findForward("page");
}
public ActionForward clear(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
EmployeeForm empForm= (EmployeeForm) form;
empForm.setEmployee(new Employee());
return mapping.findForward("add");
}
}