OrgActionTree.java
上传用户:kimgenplus
上传日期:2016-06-05
资源大小:20877k
文件大小:2k
源码类别:

OA系统

开发平台:

Java

  1. package com.bjsxt.oa.web.actions;
  2. import javax.servlet.http.HttpServletRequest;
  3. import javax.servlet.http.HttpServletResponse;
  4. import org.apache.commons.beanutils.BeanUtils;
  5. import org.apache.struts.action.ActionForm;
  6. import org.apache.struts.action.ActionForward;
  7. import org.apache.struts.action.ActionMapping;
  8. import org.apache.struts.actions.DispatchAction;
  9. import com.bjsxt.oa.SystemContext;
  10. import com.bjsxt.oa.managers.OrgManager;
  11. import com.bjsxt.oa.model.Organization;
  12. import com.bjsxt.oa.web.forms.OrgActionForm;
  13. public class OrgActionTree extends BaseAction {
  14. private OrgManager orgManager;
  15. @Override
  16. protected ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
  17. OrgActionForm oaf = (OrgActionForm)form;
  18. SystemContext.setOffset(0);
  19. SystemContext.setPagesize(Integer.MAX_VALUE);
  20. request.setAttribute("pm", orgManager.findOrgs(oaf.getParentId()));
  21. return mapping.findForward("index");
  22. }
  23. public ActionForward addInput(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
  24. return mapping.findForward("add_input");
  25. }
  26. public ActionForward add(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
  27. OrgActionForm oaf = (OrgActionForm)form;
  28. Organization org = new Organization();
  29. //将从页面上传递过来的值拷贝到Org对象
  30. BeanUtils.copyProperties(org, oaf);
  31. orgManager.addOrg(org, oaf.getParentId());
  32. request.setAttribute("org", org);
  33. return mapping.findForward("add_success");
  34. }
  35. public ActionForward del(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
  36. OrgActionForm oaf = (OrgActionForm)form;
  37. orgManager.delOrg(oaf.getId());
  38. return mapping.findForward("pub_del_success");
  39. }
  40. public void setOrgManager(OrgManager orgManager) {
  41. this.orgManager = orgManager;
  42. }
  43. }