📄 roleaction.java
字号:
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package org.jb.y2t308.team3.web.action;
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.jb.common.web.action.BaseAction;
import org.jb.y2t308.team3.biz.RoleBiz;
import org.jb.y2t308.team3.entity.SysRight;
import org.jb.y2t308.team3.entity.SysRole;
import org.jb.y2t308.team3.entity.SysUser;
import org.jb.y2t308.team3.web.form.RoleForm;
import org.jb.y2t308.team3.web.form.UserForm;
import java.util.Iterator;
import java.util.List;
/**
* MyEclipse Struts Creation date: 02-14-2009
*
* XDoclet definition:
*
* @struts.action path="/role" name="roleForm" parameter="o" scope="request"
*/
public class RoleAction extends BaseAction {
private RoleBiz roleBiz = null;
public void setRoleBiz(RoleBiz roleBiz) {
this.roleBiz = roleBiz;
}
public ActionForward toList(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
RoleForm myForm = (RoleForm) form;
this.roleBiz.getList(myForm.getItem(), myForm.getPageResult());
return mapping.findForward("list");
}
public ActionForward toAdd(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
RoleForm myForm = (RoleForm) form;
return mapping.findForward("add");
}
public ActionForward doAdd(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
RoleForm myForm = (RoleForm) form;
SysRole role = myForm.getItem();
this.roleBiz.add(role);
response.sendRedirect("role.do?o=toList");
return null;
}
public ActionForward toEdit(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
RoleForm myForm = (RoleForm) form;
Long roleId = Long.parseLong(request.getParameter("id"));
SysRole editRole = this.roleBiz.getRoleById(roleId);
request.getSession().setAttribute("editRole", editRole);
myForm.setItem(editRole);
return mapping.findForward("edit");
}
public ActionForward doEdit(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
RoleForm myForm = (RoleForm) form;
SysRole role = myForm.getItem();
SysRole editRole = (SysRole) request.getSession().getAttribute(
"editRole");
editRole.setRoleName(role.getRoleName());
editRole.setRoleDesc(role.getRoleDesc());
try {
this.roleBiz.update(editRole);
response.sendRedirect("role.do?o=toList");
return null;
} catch (Exception e) {
return mapping.findForward("edit");
}
}
public ActionForward toAssignRights(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
RoleForm myForm = (RoleForm) form;
String id = request.getParameter("id");
SysRole role = this.roleBiz.getRoleWithRights(Long.parseLong(id));
myForm.setItem(role);
List allRights = this.roleBiz.getRights();
Iterator it = allRights.iterator();
while (it.hasNext()) {
SysRight right = (SysRight) it.next();
if (role.getRights().contains(right)) {
right.setIsSelected("checked=\"on\"");
}
}
request.setAttribute("ALL_RIGHTS_LIST", allRights);
return mapping.findForward("assign_rights");
}
public ActionForward doAssignRights(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
String[] selectedRightCodes = request
.getParameterValues("selectedRights");
RoleForm myForm = (RoleForm) form;
Long roleId = myForm.getItem().getRoleId();
this.roleBiz.assignRights(roleId, selectedRightCodes);
response.sendRedirect("role.do?o=toAssignRights&id=" + roleId);
return null;
}
public ActionForward toDetail(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
RoleForm myForm = (RoleForm) form;
String roleId = request.getParameter("id");
SysRole role = this.roleBiz.getRoleById(Long.parseLong(roleId));
myForm.setItem(role);
return mapping.findForward("detail");
}
public ActionForward doDel(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
String id = request.getParameter("id");
this.roleBiz.delete(Long.parseLong(id));
response.sendRedirect("role.do?o=toList");
return null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -