groupaction.java
来自「是一个Bug系统」· Java 代码 · 共 101 行
JAVA
101 行
package com.runwit.bugreport.group;
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.runwit.bugreport.SystemCache;
import com.runwit.bugreport.model.BugStatusModel;
import com.runwit.bugreport.model.GroupModel;
import com.runwit.bugreport.services.IGroupServices;
import com.runwit.common.db.DAOFactory;
public class GroupAction extends DispatchAction {
public ActionForward add(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
GroupForm gForm = (GroupForm)form;
GroupModel gModel = new GroupModel();
//gModel.setGroupId(gForm.getGroupId());
gModel.setName(gForm.getName());
List statusList = new ArrayList();
for(int i=0; i<gForm.getStatusList().length; i++) {
BugStatusModel m = new BugStatusModel();
m.setBsid(gForm.getStatusList()[i]);
statusList.add(m);
}
gModel.setStatusList(statusList);
IGroupServices dao = DAOFactory.createGroupServices();
dao.createGroup(gModel);
return mapping.findForward("view");
}
public ActionForward modify(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
IGroupServices dao = DAOFactory.createGroupServices();
// request.setAttribute("groupList", dao.listGroups());
GroupModel model = dao.getModel(Integer.parseInt(request.getParameter("id")));
request.setAttribute("modifyModel", model);
request.setAttribute("bugStatusList", SystemCache.getInstance().getBugStatusList());
return mapping.findForward("modifyPage");
}
public ActionForward update(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
GroupForm gForm = (GroupForm)form;
GroupModel gModel = new GroupModel();
gModel.setGroupId(gForm.getGroupId());
gModel.setName(gForm.getName());
List statusList = new ArrayList();
for(int i=0; i<gForm.getStatusList().length; i++) {
BugStatusModel m = new BugStatusModel();
m.setBsid(gForm.getStatusList()[i]);
statusList.add(m);
}
gModel.setStatusList(statusList);
IGroupServices dao = DAOFactory.createGroupServices();
dao.setGroupById(gModel);
return mapping.findForward("view");
}
public ActionForward view(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
IGroupServices dao = DAOFactory.createGroupServices();
request.setAttribute("groupList", dao.listGroups());
request.setAttribute("bugStatusList", SystemCache.getInstance().getBugStatusList());
return mapping.findForward("main");
}
public ActionForward remove(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
IGroupServices dao = DAOFactory.createGroupServices();
GroupForm gForm = (GroupForm)form;
GroupModel gModel = new GroupModel();
gModel.setGroupId(gForm.getGroupId());
dao.removeGroup(gModel);
return mapping.findForward("view");
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?