orgaction.java
来自「这个主要是办公自动化系统的源代码」· Java 代码 · 共 83 行
JAVA
83 行
package com.ygp.oa.web.actions;
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.sun.org.apache.commons.beanutils.BeanUtils;
import com.ygp.oa.managers.OrgManager;
import com.ygp.oa.model.Organization;
import com.ygp.oa.web.forms.OrgActionForm;
public class OrgAction extends DispatchAction {
private OrgManager orgManager;
public void setOrgManager(OrgManager orgManager) {
this.orgManager = orgManager;
}
/**
* 打开主界面
*/
@Override
protected ActionForward unspecified(ActionMapping mapping,ActionForm form, HttpServletRequest request, HttpServletResponse response)throws Exception {
OrgActionForm oaf=(OrgActionForm)form;
int offset=0;
try {
//转换为jint类型
offset=Integer.parseInt(request.getParameter("pager.offset"));
} catch (Exception ignor) {
//这里的异常忽略
}
int pagesize=10;
request.setAttribute("pm",orgManager.findOrgs(oaf.getParentId()));
//根据parentid找出它的organization的parentid
int ppid=0;
if(oaf.getParentId()!=0){
Organization org=orgManager.findOrg(oaf.getParentId());
Organization parent=org.getParent();
if(parent!=null){
ppid=parent.getId();
}
}
request.setAttribute("ppid", ppid);
//下面对应select=true复用上面的复用分页等
if(oaf.isSelect()){
return mapping.findForward("select");
}
return mapping.findForward("index");
}
public ActionForward addInput(ActionMapping mapping,ActionForm form, HttpServletRequest request, HttpServletResponse response)throws Exception {
return mapping.findForward("add_input");
}
public ActionForward add(ActionMapping mapping,ActionForm form, HttpServletRequest request, HttpServletResponse response)throws Exception {
OrgActionForm oaf=(OrgActionForm)form;
int parentId=oaf.getParentId();
//自己修改添加机构描述,在这里获得表单信息
String description=oaf.getDescription();
Organization org=new Organization();
BeanUtils.copyProperties(org, oaf);
orgManager.addOrg(org, parentId,description);
return mapping.findForward("add_success");
}
public ActionForward del(ActionMapping mapping,ActionForm form, HttpServletRequest request, HttpServletResponse response)throws Exception {
OrgActionForm oaf=(OrgActionForm)form;
int id=oaf.getId();
orgManager.delOrg(id);
return mapping.findForward("del_success");
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?