- 浏览: 7295 次
-
最近访客 更多访客>>
最新评论
-
ttxiangyou:
呵呵,这个是乎有点乱呢?可以发到我邮箱吗?
zou_wei_f ...
不用迭代算法而快速实现的jsp树结构 -
wangjian3q:
xDataTree.js 给我一份呢??谢谢您了
wangji ...
不用迭代算法而快速实现的jsp树结构
/*
* All rights reserved.
*
* $Id: SelectReaderAction.java,v 1.14 2004/06/10 15:06:48 guoq Exp $
*/
package cn.com.detech.deinfo.mission.web;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.StringTokenizer;
import cn.com.detech.deinfo.mission.model.ReaderBean;
import cn.com.detech.deinfo.platform.DeInfoConstant;
import cn.com.detech.deinfo.users.BeanDepartment;
import cn.com.detech.deinfo.users.BeanGroup;
import cn.com.detech.deinfo.users.BeanPosition;
import cn.com.detech.deinfo.users.BeanUser;
import cn.com.detech.deinfo.users.CacheDepartments;
import cn.com.detech.deinfo.users.CacheGroups;
import cn.com.detech.deinfo.users.CacheObjects;
import cn.com.detech.deinfo.users.CachePositions;
import cn.com.detech.deinfo.users.CacheUsers;
import cn.com.detech.deinfo.users.User;
import cn.com.detech.struts.action.DEBaseAction;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForm;
/**
* 传阅人名单选择ActionBean类
* NOTE: This source is automatically generated please do not modify this file. Either subclass or
* remove the record in src/records/definitions.
* @author 曾刚
*/
public class SelectReaderAction extends DEBaseAction
{
public SelectReaderAction(){
FUNCTION_POINT = "";
}
protected static Class getClassName(){
return SelectReaderAction.class;
}
//------------------------------------------------------ Local Forwards
static final String FORWARD_success = "success";
static final String FORWARD_failure = "failure";
static final String FORWARD_Select = "Select";
static final String FORWARD_Select2 = "Select2";//add by weij;
static final String FORWARD_Back = "Back";//add by weij;
static final String FORWARD_ChangeDept = "ChangeDept";
static final String FORWARD_ChangeGroup = "ChangeGroup";
static final String FORWARD_Save = "Save";
/*static final*/ String DEFAULT_POSITION = "待定";
//------------------------------------------------------ Action Methods
/**
* Process the specified HTTP request, and create the corresponding HTTP
* response (or forward to another web component that will create it).
* Return an ActionForward instance describing where and how
* control should be forwarded, or null if the response has
* already been completed.
*
* @param mapping The ActionMapping used to select this instance
* @param aform The optional ActionForm bean for this request (if any)
* @param request 待处理的HTTP请求
* @param response 生成的HTTP回应
* @return 页面迁移
* @throws Exception
*/
public ActionForward execute(
ActionMapping mapping,
ActionForm myform,
HttpServletRequest request,
HttpServletResponse response,
User user)
throws Exception
{try{
SelectReaderForm form = (SelectReaderForm)myform;
String action = form.getAction();
if ( action == null ) {
action = "Select";
}
log.debug("enter sel people ,action is:"+action);
DEFAULT_POSITION=getMessage("mission.selectreader.tobe");
if(action.equalsIgnoreCase("Select")){
return doSelect(mapping, form, request, response, user);
}
// add by weij;
if(action.equalsIgnoreCase("Select2")){
return doSelect2(mapping, form, request, response, user);
}
if(action.equalsIgnoreCase("ChangeDept")){
return doChangeDept(mapping, form, request, response, user);
}
if(action.equalsIgnoreCase("ChangeGroup")){
return doChangeGroup(mapping, form, request, response, user);
}
if(action.equalsIgnoreCase("Save")){
return doSave(mapping, form, request, response, user);
}
if(action.equalsIgnoreCase("Cancel")){
return doCancel(mapping, form, request, response, user);
}
// add by weij;
if(action.equalsIgnoreCase("Save2")){
return doSave2(mapping, form, request, response, user);
}
}catch(Exception e){e.printStackTrace();
}
return mapping.findForward(FORWARD_Select);
}
/**
*
* @param mapping
* @param form
* @param request
* @throws Exception
* @return ActionForward
*/
public ActionForward doSelect(ActionMapping mapping,
SelectReaderForm form,
HttpServletRequest request,
HttpServletResponse response,
User user)
throws Exception {
// Add your logic code here
form.reset();
HttpSession session = request.getSession();
CacheObjects objCacheObjects = (CacheObjects)session.getServletContext().getAttribute(DeInfoConstant.PLATFORM_CONTEXT);
CacheUsers users = objCacheObjects.getUsers();
CacheDepartments departments = objCacheObjects.getDepartments();
CacheGroups groups = objCacheObjects.getGroups();
form.reset();
ArrayList deptList = departments.getDepartments();
BeanDepartment nbd = new BeanDepartment();
nbd.setDeptID(9998);
nbd.setDepartmentName(getMessage("mission.selectreader.sel_dept"));
deptList.add(0, nbd);
form.setDeptList(deptList);
form.setSelDeptID("9998");
//加用户组
Iterator it = groups.getIterator0();
ArrayList groupList = new ArrayList();
while (it.hasNext()) {
BeanGroup nbg = (BeanGroup) it.next();
groupList.add(nbg);
}
BeanGroup nbg = new BeanGroup();
nbg.setGroupID(9998);
nbg.setGroupName(getMessage("mission.selectreader.sel_group"));
groupList.add(0, nbg);
form.setGroupList(groupList);
form.setSelGroupID("9998");
form.setEmpList(new ArrayList());
ArrayList readerList = new ArrayList();
session.removeAttribute("ReaderIDs");//add by weij;
/*ArrayList readerIDList = (ArrayList)session.getAttribute("ReaderIDs");
if (readerIDList == null)
readerIDList = new ArrayList();
session.setAttribute("readerIDList", readerIDList); //生成副本
if (readerIDList != null && readerIDList.size() > 0) {
Iterator ior = readerIDList.iterator();
ArrayList readerNameList = new ArrayList();
session.removeAttribute("ReaderNames");//add by weij;
String tmpStr = (String)session.getAttribute("ReaderNames");
if (tmpStr == null)
tmpStr = new String("");
session.setAttribute("readerNameStr", tmpStr); //生成副本
if (tmpStr != null && !tmpStr.equals("")) {
StringTokenizer st = new StringTokenizer(tmpStr, "#");
while(st.hasMoreTokens()) {
readerNameList.add((String)st.nextElement());
}
}
Iterator ier = readerNameList.iterator();
while (ior.hasNext()) {
ReaderBean nrb = new ReaderBean();
int userID = Integer.parseInt((String)ior.next());
String readerStr = (String)ier.next();
StringTokenizer st = new StringTokenizer(readerStr, "&&&&&&&&");
if(st.hasMoreTokens()) {
nrb.setUserName((String)st.nextElement());
nrb.setDeptName((String)st.nextElement());
}
StringTokenizer st1 = new StringTokenizer((String)st.nextElement(), "&&");
if(st1.hasMoreTokens()) {
nrb.setPositionName((String)st1.nextElement());
}
nrb.setUserID(userID);
readerList.add(nrb);
}
form.setReaderList(readerList);
String[] as = new String[1];
as[0] = "";
form.setSelectedIDStr(as);
}
else*/
form.setReaderList(readerList);
return (mapping.findForward(FORWARD_Select));
}
/**
*
* @param mapping
* @param form
* @param request
* @throws Exception
* @return ActionForward
*/
public ActionForward doSelect2(ActionMapping mapping,
SelectReaderForm form,
HttpServletRequest request,
HttpServletResponse response,
User user)
throws Exception {
// Add your logic code here
form.reset();
HttpSession session = request.getSession();
CacheObjects objCacheObjects = (CacheObjects)session.getServletContext().getAttribute(DeInfoConstant.PLATFORM_CONTEXT);
CacheUsers users = objCacheObjects.getUsers();
CacheDepartments departments = objCacheObjects.getDepartments();
CacheGroups groups = objCacheObjects.getGroups();
form.reset();
ArrayList deptList = departments.getDepartments();
BeanDepartment nbd = new BeanDepartment();
nbd.setDeptID(9998);
nbd.setDepartmentName(getMessage("mission.selectreader.sel_dept"));
deptList.add(0, nbd);
form.setDeptList(deptList);
form.setSelDeptID("9998");
//加用户组
Iterator it = groups.getIterator0();
ArrayList groupList = new ArrayList();
while (it.hasNext()) {
BeanGroup nbg = (BeanGroup) it.next();
groupList.add(nbg);
}
BeanGroup nbg = new BeanGroup();
nbg.setGroupID(9998);
nbg.setGroupName(getMessage("mission.selectreader.sel_group"));
groupList.add(0, nbg);
form.setGroupList(groupList);
form.setSelGroupID("9998");
form.setEmpList(new ArrayList());
ArrayList readerList = new ArrayList();
session.removeAttribute("ReaderIDs2");//add by weij;
/*ArrayList readerIDList = (ArrayList)session.getAttribute("ReaderIDs2");
if (readerIDList == null)
readerIDList = new ArrayList();
session.setAttribute("readerIDList", readerIDList); //生成副本
if (readerIDList != null && readerIDList.size() > 0) {
Iterator ior = readerIDList.iterator();
ArrayList readerNameList = new ArrayList();
session.removeAttribute("ReaderNames");//add by weij;
String tmpStr = (String)session.getAttribute("ReaderNames");
if (tmpStr == null)
tmpStr = new String("");
session.setAttribute("readerNameStr", tmpStr); //生成副本
if (tmpStr != null && !tmpStr.equals("")) {
StringTokenizer st = new StringTokenizer(tmpStr, "#");
while(st.hasMoreTokens()) {
readerNameList.add((String)st.nextElement());
}
}
Iterator ier = readerNameList.iterator();
while (ior.hasNext()) {
ReaderBean nrb = new ReaderBean();
int userID = Integer.parseInt((String)ior.next());
String readerStr = (String)ier.next();
StringTokenizer st = new StringTokenizer(readerStr, "&&&&&&&&");
if(st.hasMoreTokens()) {
nrb.setUserName((String)st.nextElement());
nrb.setDeptName((String)st.nextElement());
}
StringTokenizer st1 = new StringTokenizer((String)st.nextElement(), "&&");
if(st1.hasMoreTokens()) {
nrb.setPositionName((String)st1.nextElement());
}
nrb.setUserID(userID);
readerList.add(nrb);
}
form.setReaderList(readerList);
String[] as = new String[1];
as[0] = "";
form.setSelectedIDStr(as);
}
else*/
form.setReaderList(readerList);
return (mapping.findForward(FORWARD_Select2));
}
/**
*
* @param mapping
* @param form
* @param request
* @throws Exception
* @return ActionForward
*/
public ActionForward doChangeDept(ActionMapping mapping,
SelectReaderForm form,
HttpServletRequest request,
HttpServletResponse response,
User user)
throws Exception {
// Add your logic code here
HttpSession session = request.getSession();
CacheObjects objCacheObjects = (CacheObjects)session.getServletContext().getAttribute(DeInfoConstant.PLATFORM_CONTEXT);
CacheUsers users = objCacheObjects.getUsers();
CachePositions positions = objCacheObjects.getPositions();
CacheDepartments departments = objCacheObjects.getDepartments();
String selDeptID = form.getSelDeptID();
String readerNameStr = form.getReaderNameStr();
session.setAttribute("readerNameStr", readerNameStr);
String[] tmpIDArray = form.getSelectedIDStr();
if(tmpIDArray!=null)
log.debug("tmpIDArray.length == "+tmpIDArray.length);
form.reset2();
ArrayList readerIDList = new ArrayList();
if (tmpIDArray != null) {
for (int i = 0; i < tmpIDArray.length; i ++) {
readerIDList.add(tmpIDArray[i]);
}
session.setAttribute("readerIDList", readerIDList);
}
ArrayList tmpList = new ArrayList();
ArrayList empList = new ArrayList();
if (selDeptID == null || selDeptID.equals("") || selDeptID.equals("0")) {
form.setAction("Select");
return (mapping.findForward(FORWARD_Select));
}
if (selDeptID.equals("9998")) {
form.setEmpList(empList);
}
else {
int deptID = Integer.parseInt(selDeptID);
String departmentName = ((BeanDepartment)departments.getDeptByID(deptID)).getDepartmentName();
tmpList = users.getUsersByDeptID(deptID);
Iterator it = tmpList.iterator();
while(it.hasNext()) {
BeanUser nbu = (BeanUser)it.next();
int userID = nbu.getUserID();
int positionID = 0;
if (userID == 1) { //如果是系统管理员
positionID = 1; //直接设置其职务为待定
} else {
positionID = users.getUserPosition(userID, deptID);
}
//int positionID = users.getUserPosition(userID, deptID);
BeanPosition beanp = (BeanPosition) positions.getPositionByID(positionID);
String positionName = getMessage("mission.selectreader.tobe");
if(beanp!=null) positionName = beanp.getPosition();
String userName = "";
BeanUser buser = (BeanUser) users.getUserByID(userID);
if (buser != null) {
userName = buser.getUserName();
}
//String userName = ((BeanUser)users.getUserByID(userID)).getUserName();
ReaderBean rb = new ReaderBean();
rb.setUserID(userID);
rb.setUserName(userName);
rb.setDeptID(deptID);
rb.setDeptName(departmentName);
rb.setPositionID(positionID);
rb.setPositionName(positionName);
empList.add(rb);
}
}
form.setEmpList(empList);
form.setSelDeptID(selDeptID);
form.setSelGroupID("9998");
ArrayList readerList = new ArrayList();
readerIDList = (ArrayList) session.getAttribute("readerIDList");
if (readerIDList != null && readerIDList.size() > 0) {
Iterator ior = readerIDList.iterator();
while (ior.hasNext()) {
ReaderBean nrb = new ReaderBean();
String ids = (String) ior.next();
StringTokenizer st = new StringTokenizer(ids, "#");
int i = 0;
int userID = 0;
int deptID = 0;
int positionID = 0;
while (st.hasMoreTokens()) {
if (i == 0)
userID = Integer.parseInt((String) st.nextElement());
else if (i == 1)
deptID = Integer.parseInt((String) st.nextElement());
else if (i == 2)
positionID =
Integer.parseInt((String) st.nextElement());
;
i++;
}
String userName =
((BeanUser) users.getUserByID(userID)).getUserName();
String deptName =
((BeanDepartment) departments.getDeptByID(deptID))
.getDepartmentName();
String positionName = getPosition(positions, positionID);
nrb.setUserID(userID);
nrb.setUserName(userName);
nrb.setDeptID(deptID);
nrb.setDeptName(deptName);
nrb.setPositionID(positionID);
nrb.setPositionName(positionName);
readerList.add(nrb);
}
/*ArrayList readerList = new ArrayList();
readerIDList = (ArrayList)session.getAttribute("readerIDList");
if (readerIDList != null && readerIDList.size() > 0) {
Iterator ior = readerIDList.iterator();
ArrayList readerNameList = new ArrayList();
String tmpStr = (String)session.getAttribute("readerNameStr");
if (tmpStr != null && !tmpStr.equals("")) {
StringTokenizer st = new StringTokenizer(tmpStr, "#");
while(st.hasMoreTokens()) {
readerNameList.add((String)st.nextElement());
}
}
Iterator ier = readerNameList.iterator();
while (ior.hasNext()) {
ReaderBean nrb = new ReaderBean();
int userID = Integer.parseInt((String)ior.next());
String readerStr = "";
if(ier.hasNext())
readerStr = (String)ier.next();
StringTokenizer st = new StringTokenizer(readerStr, "&&&&&&&&");
if(st.hasMoreTokens()) {
nrb.setUserName((String)st.nextElement());
nrb.setDeptName((String)st.nextElement());
}
String ststr = "";
if(st.hasMoreElements()) ststr = (String)st.nextElement();
StringTokenizer st1 = new StringTokenizer(ststr, "&&");
if(st1.hasMoreTokens()) {
nrb.setPositionName((String)st1.nextElement());
}
nrb.setUserID(userID);
readerList.add(nrb);
}*/
form.setReaderList(readerList);
form.setSelectedIDStr(null);
}
else
form.setReaderList(readerList);
return (mapping.findForward(FORWARD_Select));
}
/**
*
* @param mapping
* @param form
* @param request
* @throws Exception
* @return ActionForward
*/
public ActionForward doChangeGroup(ActionMapping mapping,
SelectReaderForm form,
HttpServletRequest request,
HttpServletResponse response,
User user)
throws Exception {
// Add your logic code here
HttpSession session = request.getSession();
CacheObjects objCacheObjects =
(CacheObjects) session.getServletContext().getAttribute(
DeInfoConstant.PLATFORM_CONTEXT);
CacheUsers users = objCacheObjects.getUsers();
CacheDepartments departments = objCacheObjects.getDepartments();
CachePositions positions = objCacheObjects.getPositions();
CacheGroups groups = objCacheObjects.getGroups();
String selGroupID = form.getSelGroupID();
String readerNameStr = form.getReaderNameStr();
//session.removeAttribute("readerNameStr");
session.setAttribute("readerNameStr", readerNameStr);
String[] tmpIDArray = form.getSelectedIDStr();
form.reset();
ArrayList readerIDList = new ArrayList();
if (tmpIDArray != null) {
for (int i = 0; i < tmpIDArray.length; i++) {
readerIDList.add(tmpIDArray[i]);
}
}
//session.removeAttribute("readerIDList");
session.setAttribute("readerIDList", readerIDList);
ArrayList empList = new ArrayList();
ArrayList tmpList = new ArrayList();
HashMap hm = new HashMap();
if (selGroupID == null
|| selGroupID.equals("")
|| selGroupID.equals("0")) {
form.setAction("Select");
return (mapping.findForward(FORWARD_Select));
}
if (selGroupID.equals("9998")) {
form.setEmpList(empList);
} else {
tmpList = users.getUsersByGroupID(Integer.parseInt(selGroupID));
Iterator it = tmpList.iterator();
while (it.hasNext()) {
BeanGroup bg = (BeanGroup) it.next();
int userID = bg.getUserID();
int deptID = bg.getDeptID();
//要排除用户组中用户重复的情况
if (userID == 0 && deptID == 0) { //所有用户都属于该用户组
ArrayList alist = users.getUsers();
Iterator ior = alist.iterator();
while (ior.hasNext()) {
BeanUser bu = (BeanUser) ior.next();
int uid = bu.getUserID();
String userName = users.getUserByID(uid).getUserName();
int did =
((BeanDepartment) (users
.getDeptsByUserID(uid)
.get(0)))
.getDeptID();
String departmentName =
((BeanDepartment) (users
.getDeptsByUserID(uid)
.get(0)))
.getDepartmentName();
int pid = users.getUserPosition(uid, did);
String positionName = getPosition(positions, pid);
ReaderBean rb = new ReaderBean();
rb.setUserID(uid);
rb.setUserName(userName);
rb.setDeptID(did);
rb.setDeptName(departmentName);
rb.setPositionID(pid);
rb.setPositionName(positionName);
hm.put(new Integer(uid), rb);
}
} else if (userID == 0 && deptID != 0) { //某部门下的所有用户属于该用户组
ArrayList alist = users.getUsersByDeptID(deptID);
Iterator irr = alist.iterator();
while (irr.hasNext()) {
BeanUser bu = (BeanUser) irr.next();
int uid = bu.getUserID();
String userName = users.getUserByID(uid).getUserName();
String departmentName =
((BeanDepartment) departments.getDeptByID(deptID))
.getDepartmentName();
int pid = users.getUserPosition(uid, deptID);
String positionName = getPosition(positions, pid);
ReaderBean rb = new ReaderBean();
rb.setUserID(uid);
rb.setUserName(userName);
rb.setDeptID(deptID);
rb.setDeptName(departmentName);
rb.setPositionID(pid);
rb.setPositionName(positionName);
hm.put(new Integer(uid), rb);
}
} else if (userID != 0) {
String userName = users.getUserByID(userID).getUserName();
String departmentName =
((BeanDepartment) departments.getDeptByID(deptID))
.getDepartmentName();
//log.error("开始取userID:" + userID + ",deptID:" + deptID + " 对应的positionID的值。");
int positionID = 0;
if (userID == 1) { //如果是系统管理员
positionID = 1; //直接设置其职务为代定
} else {
positionID = users.getUserPosition(userID, deptID);
}
//log.error("positionID:####" + positionID + "####");
String positionName = getPosition(positions, positionID);
ReaderBean rb = new ReaderBean();
rb.setUserID(userID);
rb.setUserName(userName);
rb.setDeptID(deptID);
rb.setDeptName(departmentName);
rb.setPositionID(positionID);
rb.setPositionName(positionName);
hm.put(new Integer(userID), rb);
}
}
}
empList.addAll(hm.values());
form.setEmpList(empList);
form.setSelGroupID(selGroupID);
form.setSelDeptID("9998");
ArrayList readerList = new ArrayList();
readerIDList = (ArrayList) session.getAttribute("readerIDList");
if (readerIDList != null && readerIDList.size() > 0) {
Iterator ior = readerIDList.iterator();
while (ior.hasNext()) {
ReaderBean nrb = new ReaderBean();
String ids = (String) ior.next();
StringTokenizer st = new StringTokenizer(ids, "#");
int i = 0;
int userID = 0;
int deptID = 0;
int positionID = 0;
while (st.hasMoreTokens()) {
if (i == 0)
userID = Integer.parseInt((String) st.nextElement());
else if (i == 1)
deptID = Integer.parseInt((String) st.nextElement());
else if (i == 2)
positionID =
Integer.parseInt((String) st.nextElement());
i++;
}
String userName =
((BeanUser) users.getUserByID(userID)).getUserName();
String deptName =
((BeanDepartment) departments.getDeptByID(deptID))
.getDepartmentName();
String positionName = getPosition(positions, positionID);
nrb.setUserID(userID);
nrb.setUserName(userName);
nrb.setDeptID(deptID);
nrb.setDeptName(deptName);
nrb.setPositionID(positionID);
nrb.setPositionName(positionName);
readerList.add(nrb);
}
/*ArrayList readerNameList = new ArrayList();
String tmpStr = (String)session.getAttribute("readerNameStr");
if (tmpStr != null && !tmpStr.equals("")) {
StringTokenizer st = new StringTokenizer(tmpStr, "#");
while(st.hasMoreTokens()) {
readerNameList.add((String)st.nextElement());
}
}
Iterator ier = readerNameList.iterator();
while (ior.hasNext()) {
ReaderBean nrb = new ReaderBean();
int userID = Integer.parseInt((String)ior.next());
String readerStr = (String)ier.next();
StringTokenizer st = new StringTokenizer(readerStr, "&&&&&&&&");
if(st.hasMoreTokens()) {
nrb.setUserName((String)st.nextElement());
nrb.setDeptName((String)st.nextElement());
}
StringTokenizer st1 = new StringTokenizer((String)st.nextElement(), "&&");
if(st1.hasMoreTokens()) {
nrb.setPositionName((String)st1.nextElement());
}
nrb.setUserID(userID);
readerList.add(nrb);
}*/
form.setReaderList(readerList);
form.setSelectedIDStr(null);
} else {
form.setReaderList(readerList);
form.setSelectedIDStr(null);
}
return (mapping.findForward(FORWARD_Select));
}
/**
*
* @param mapping
* @param form
* @param request
* @throws Exception
* @return ActionForward
*/
public ActionForward doSave(ActionMapping mapping,
SelectReaderForm form,
HttpServletRequest request,
HttpServletResponse response,
User user)
throws Exception {
// Add your logic code here
HttpSession session = request.getSession();
String readerNameStr = form.getReaderNameStr();
session.removeAttribute("readerNameStr");
setReaderID("ReaderIDs",mapping,form,request,response,user);
session.removeAttribute("readerIDList");
//}
return (mapping.findForward(FORWARD_Back));
}
/**
*
* @param mapping
* @param form
* @param request
* @throws Exception
* @return ActionForward
*/
public ActionForward doCancel(ActionMapping mapping,
SelectReaderForm form,
HttpServletRequest request,
HttpServletResponse response,
User user)
throws Exception {
log.debug("enter save:");
// Add your logic code here
HttpSession session = request.getSession();
String readerNameStr = form.getReaderNameStr();
session.removeAttribute("readerNameStr");
session.removeAttribute("readerIDList");
form.reset();
return (mapping.findForward(FORWARD_Back));
}
// add by weij;
/**
*
* @param mapping
* @param form
* @param request
* @throws Exception
* @return ActionForward
*/
public ActionForward doSave2(ActionMapping mapping,
SelectReaderForm form,
HttpServletRequest request,
HttpServletResponse response,
User user)
throws Exception {
// Add your logic code here
HttpSession session = request.getSession();
String readerNameStr = form.getReaderNameStr();
session.removeAttribute("readerNameStr");
setReaderID("ReaderIDs2",mapping,form,request,response,user);
session.removeAttribute("readerIDList");
//}
return (mapping.findForward(FORWARD_Back));
}
private String getPosition(CachePositions posts, int pid) {
String position = DEFAULT_POSITION;
BeanPosition bpost0 = (BeanPosition) posts.getPositionByID(pid);
if (bpost0 != null) {
position = bpost0.getPosition();
}
return position;
}
private boolean setReaderID(String attrName,
ActionMapping mapping,
SelectReaderForm form,
HttpServletRequest request,
HttpServletResponse response,
User user)
{
String[] tmpIDArray = form.getSelectedIDStr();
ArrayList readerIDList = new ArrayList();
if (tmpIDArray != null) {
for (int i = 0; i < tmpIDArray.length; i ++) {
readerIDList.add(tmpIDArray[i]);
log.debug("tmpIDArray[i]:"+tmpIDArray[i]);
}
}
if (readerIDList != null && readerIDList.size() > 0) {
ArrayList readerList = new ArrayList();
Iterator ior = readerIDList.iterator();
while (ior.hasNext()) {
ReaderBean nrb = new ReaderBean();
String ids = (String) ior.next();
log.debug("ids: "+ids);
StringTokenizer st = new StringTokenizer(ids, "#");
log.debug("StringTokenizer:"+st.toString());
int i = 0;
int userID = 0;
int deptID = 0;
int positionID = 0;
while (st.hasMoreTokens()) {
if (i == 0)
userID = Integer.parseInt((String) st.nextElement());
else if (i == 1)
deptID = Integer.parseInt((String) st.nextElement());
else if (i == 2)
positionID =
Integer.parseInt((String) st.nextElement());
;
i++;
}
log.debug("userid:"+userID);
readerList.add((new Integer(userID)).toString());
}
System.out.println("arrname:"+attrName);
HttpSession session = request.getSession();
session.setAttribute(attrName,readerList);
if(readerList!=null)
System.out.println("readerList.size:"+readerList.size());
else
System.out.println("readerList is null!!!");
}
return true;
}
}
* All rights reserved.
*
* $Id: SelectReaderAction.java,v 1.14 2004/06/10 15:06:48 guoq Exp $
*/
package cn.com.detech.deinfo.mission.web;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.StringTokenizer;
import cn.com.detech.deinfo.mission.model.ReaderBean;
import cn.com.detech.deinfo.platform.DeInfoConstant;
import cn.com.detech.deinfo.users.BeanDepartment;
import cn.com.detech.deinfo.users.BeanGroup;
import cn.com.detech.deinfo.users.BeanPosition;
import cn.com.detech.deinfo.users.BeanUser;
import cn.com.detech.deinfo.users.CacheDepartments;
import cn.com.detech.deinfo.users.CacheGroups;
import cn.com.detech.deinfo.users.CacheObjects;
import cn.com.detech.deinfo.users.CachePositions;
import cn.com.detech.deinfo.users.CacheUsers;
import cn.com.detech.deinfo.users.User;
import cn.com.detech.struts.action.DEBaseAction;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForm;
/**
* 传阅人名单选择ActionBean类
* NOTE: This source is automatically generated please do not modify this file. Either subclass or
* remove the record in src/records/definitions.
* @author 曾刚
*/
public class SelectReaderAction extends DEBaseAction
{
public SelectReaderAction(){
FUNCTION_POINT = "";
}
protected static Class getClassName(){
return SelectReaderAction.class;
}
//------------------------------------------------------ Local Forwards
static final String FORWARD_success = "success";
static final String FORWARD_failure = "failure";
static final String FORWARD_Select = "Select";
static final String FORWARD_Select2 = "Select2";//add by weij;
static final String FORWARD_Back = "Back";//add by weij;
static final String FORWARD_ChangeDept = "ChangeDept";
static final String FORWARD_ChangeGroup = "ChangeGroup";
static final String FORWARD_Save = "Save";
/*static final*/ String DEFAULT_POSITION = "待定";
//------------------------------------------------------ Action Methods
/**
* Process the specified HTTP request, and create the corresponding HTTP
* response (or forward to another web component that will create it).
* Return an ActionForward instance describing where and how
* control should be forwarded, or null if the response has
* already been completed.
*
* @param mapping The ActionMapping used to select this instance
* @param aform The optional ActionForm bean for this request (if any)
* @param request 待处理的HTTP请求
* @param response 生成的HTTP回应
* @return 页面迁移
* @throws Exception
*/
public ActionForward execute(
ActionMapping mapping,
ActionForm myform,
HttpServletRequest request,
HttpServletResponse response,
User user)
throws Exception
{try{
SelectReaderForm form = (SelectReaderForm)myform;
String action = form.getAction();
if ( action == null ) {
action = "Select";
}
log.debug("enter sel people ,action is:"+action);
DEFAULT_POSITION=getMessage("mission.selectreader.tobe");
if(action.equalsIgnoreCase("Select")){
return doSelect(mapping, form, request, response, user);
}
// add by weij;
if(action.equalsIgnoreCase("Select2")){
return doSelect2(mapping, form, request, response, user);
}
if(action.equalsIgnoreCase("ChangeDept")){
return doChangeDept(mapping, form, request, response, user);
}
if(action.equalsIgnoreCase("ChangeGroup")){
return doChangeGroup(mapping, form, request, response, user);
}
if(action.equalsIgnoreCase("Save")){
return doSave(mapping, form, request, response, user);
}
if(action.equalsIgnoreCase("Cancel")){
return doCancel(mapping, form, request, response, user);
}
// add by weij;
if(action.equalsIgnoreCase("Save2")){
return doSave2(mapping, form, request, response, user);
}
}catch(Exception e){e.printStackTrace();
}
return mapping.findForward(FORWARD_Select);
}
/**
*
* @param mapping
* @param form
* @param request
* @throws Exception
* @return ActionForward
*/
public ActionForward doSelect(ActionMapping mapping,
SelectReaderForm form,
HttpServletRequest request,
HttpServletResponse response,
User user)
throws Exception {
// Add your logic code here
form.reset();
HttpSession session = request.getSession();
CacheObjects objCacheObjects = (CacheObjects)session.getServletContext().getAttribute(DeInfoConstant.PLATFORM_CONTEXT);
CacheUsers users = objCacheObjects.getUsers();
CacheDepartments departments = objCacheObjects.getDepartments();
CacheGroups groups = objCacheObjects.getGroups();
form.reset();
ArrayList deptList = departments.getDepartments();
BeanDepartment nbd = new BeanDepartment();
nbd.setDeptID(9998);
nbd.setDepartmentName(getMessage("mission.selectreader.sel_dept"));
deptList.add(0, nbd);
form.setDeptList(deptList);
form.setSelDeptID("9998");
//加用户组
Iterator it = groups.getIterator0();
ArrayList groupList = new ArrayList();
while (it.hasNext()) {
BeanGroup nbg = (BeanGroup) it.next();
groupList.add(nbg);
}
BeanGroup nbg = new BeanGroup();
nbg.setGroupID(9998);
nbg.setGroupName(getMessage("mission.selectreader.sel_group"));
groupList.add(0, nbg);
form.setGroupList(groupList);
form.setSelGroupID("9998");
form.setEmpList(new ArrayList());
ArrayList readerList = new ArrayList();
session.removeAttribute("ReaderIDs");//add by weij;
/*ArrayList readerIDList = (ArrayList)session.getAttribute("ReaderIDs");
if (readerIDList == null)
readerIDList = new ArrayList();
session.setAttribute("readerIDList", readerIDList); //生成副本
if (readerIDList != null && readerIDList.size() > 0) {
Iterator ior = readerIDList.iterator();
ArrayList readerNameList = new ArrayList();
session.removeAttribute("ReaderNames");//add by weij;
String tmpStr = (String)session.getAttribute("ReaderNames");
if (tmpStr == null)
tmpStr = new String("");
session.setAttribute("readerNameStr", tmpStr); //生成副本
if (tmpStr != null && !tmpStr.equals("")) {
StringTokenizer st = new StringTokenizer(tmpStr, "#");
while(st.hasMoreTokens()) {
readerNameList.add((String)st.nextElement());
}
}
Iterator ier = readerNameList.iterator();
while (ior.hasNext()) {
ReaderBean nrb = new ReaderBean();
int userID = Integer.parseInt((String)ior.next());
String readerStr = (String)ier.next();
StringTokenizer st = new StringTokenizer(readerStr, "&&&&&&&&");
if(st.hasMoreTokens()) {
nrb.setUserName((String)st.nextElement());
nrb.setDeptName((String)st.nextElement());
}
StringTokenizer st1 = new StringTokenizer((String)st.nextElement(), "&&");
if(st1.hasMoreTokens()) {
nrb.setPositionName((String)st1.nextElement());
}
nrb.setUserID(userID);
readerList.add(nrb);
}
form.setReaderList(readerList);
String[] as = new String[1];
as[0] = "";
form.setSelectedIDStr(as);
}
else*/
form.setReaderList(readerList);
return (mapping.findForward(FORWARD_Select));
}
/**
*
* @param mapping
* @param form
* @param request
* @throws Exception
* @return ActionForward
*/
public ActionForward doSelect2(ActionMapping mapping,
SelectReaderForm form,
HttpServletRequest request,
HttpServletResponse response,
User user)
throws Exception {
// Add your logic code here
form.reset();
HttpSession session = request.getSession();
CacheObjects objCacheObjects = (CacheObjects)session.getServletContext().getAttribute(DeInfoConstant.PLATFORM_CONTEXT);
CacheUsers users = objCacheObjects.getUsers();
CacheDepartments departments = objCacheObjects.getDepartments();
CacheGroups groups = objCacheObjects.getGroups();
form.reset();
ArrayList deptList = departments.getDepartments();
BeanDepartment nbd = new BeanDepartment();
nbd.setDeptID(9998);
nbd.setDepartmentName(getMessage("mission.selectreader.sel_dept"));
deptList.add(0, nbd);
form.setDeptList(deptList);
form.setSelDeptID("9998");
//加用户组
Iterator it = groups.getIterator0();
ArrayList groupList = new ArrayList();
while (it.hasNext()) {
BeanGroup nbg = (BeanGroup) it.next();
groupList.add(nbg);
}
BeanGroup nbg = new BeanGroup();
nbg.setGroupID(9998);
nbg.setGroupName(getMessage("mission.selectreader.sel_group"));
groupList.add(0, nbg);
form.setGroupList(groupList);
form.setSelGroupID("9998");
form.setEmpList(new ArrayList());
ArrayList readerList = new ArrayList();
session.removeAttribute("ReaderIDs2");//add by weij;
/*ArrayList readerIDList = (ArrayList)session.getAttribute("ReaderIDs2");
if (readerIDList == null)
readerIDList = new ArrayList();
session.setAttribute("readerIDList", readerIDList); //生成副本
if (readerIDList != null && readerIDList.size() > 0) {
Iterator ior = readerIDList.iterator();
ArrayList readerNameList = new ArrayList();
session.removeAttribute("ReaderNames");//add by weij;
String tmpStr = (String)session.getAttribute("ReaderNames");
if (tmpStr == null)
tmpStr = new String("");
session.setAttribute("readerNameStr", tmpStr); //生成副本
if (tmpStr != null && !tmpStr.equals("")) {
StringTokenizer st = new StringTokenizer(tmpStr, "#");
while(st.hasMoreTokens()) {
readerNameList.add((String)st.nextElement());
}
}
Iterator ier = readerNameList.iterator();
while (ior.hasNext()) {
ReaderBean nrb = new ReaderBean();
int userID = Integer.parseInt((String)ior.next());
String readerStr = (String)ier.next();
StringTokenizer st = new StringTokenizer(readerStr, "&&&&&&&&");
if(st.hasMoreTokens()) {
nrb.setUserName((String)st.nextElement());
nrb.setDeptName((String)st.nextElement());
}
StringTokenizer st1 = new StringTokenizer((String)st.nextElement(), "&&");
if(st1.hasMoreTokens()) {
nrb.setPositionName((String)st1.nextElement());
}
nrb.setUserID(userID);
readerList.add(nrb);
}
form.setReaderList(readerList);
String[] as = new String[1];
as[0] = "";
form.setSelectedIDStr(as);
}
else*/
form.setReaderList(readerList);
return (mapping.findForward(FORWARD_Select2));
}
/**
*
* @param mapping
* @param form
* @param request
* @throws Exception
* @return ActionForward
*/
public ActionForward doChangeDept(ActionMapping mapping,
SelectReaderForm form,
HttpServletRequest request,
HttpServletResponse response,
User user)
throws Exception {
// Add your logic code here
HttpSession session = request.getSession();
CacheObjects objCacheObjects = (CacheObjects)session.getServletContext().getAttribute(DeInfoConstant.PLATFORM_CONTEXT);
CacheUsers users = objCacheObjects.getUsers();
CachePositions positions = objCacheObjects.getPositions();
CacheDepartments departments = objCacheObjects.getDepartments();
String selDeptID = form.getSelDeptID();
String readerNameStr = form.getReaderNameStr();
session.setAttribute("readerNameStr", readerNameStr);
String[] tmpIDArray = form.getSelectedIDStr();
if(tmpIDArray!=null)
log.debug("tmpIDArray.length == "+tmpIDArray.length);
form.reset2();
ArrayList readerIDList = new ArrayList();
if (tmpIDArray != null) {
for (int i = 0; i < tmpIDArray.length; i ++) {
readerIDList.add(tmpIDArray[i]);
}
session.setAttribute("readerIDList", readerIDList);
}
ArrayList tmpList = new ArrayList();
ArrayList empList = new ArrayList();
if (selDeptID == null || selDeptID.equals("") || selDeptID.equals("0")) {
form.setAction("Select");
return (mapping.findForward(FORWARD_Select));
}
if (selDeptID.equals("9998")) {
form.setEmpList(empList);
}
else {
int deptID = Integer.parseInt(selDeptID);
String departmentName = ((BeanDepartment)departments.getDeptByID(deptID)).getDepartmentName();
tmpList = users.getUsersByDeptID(deptID);
Iterator it = tmpList.iterator();
while(it.hasNext()) {
BeanUser nbu = (BeanUser)it.next();
int userID = nbu.getUserID();
int positionID = 0;
if (userID == 1) { //如果是系统管理员
positionID = 1; //直接设置其职务为待定
} else {
positionID = users.getUserPosition(userID, deptID);
}
//int positionID = users.getUserPosition(userID, deptID);
BeanPosition beanp = (BeanPosition) positions.getPositionByID(positionID);
String positionName = getMessage("mission.selectreader.tobe");
if(beanp!=null) positionName = beanp.getPosition();
String userName = "";
BeanUser buser = (BeanUser) users.getUserByID(userID);
if (buser != null) {
userName = buser.getUserName();
}
//String userName = ((BeanUser)users.getUserByID(userID)).getUserName();
ReaderBean rb = new ReaderBean();
rb.setUserID(userID);
rb.setUserName(userName);
rb.setDeptID(deptID);
rb.setDeptName(departmentName);
rb.setPositionID(positionID);
rb.setPositionName(positionName);
empList.add(rb);
}
}
form.setEmpList(empList);
form.setSelDeptID(selDeptID);
form.setSelGroupID("9998");
ArrayList readerList = new ArrayList();
readerIDList = (ArrayList) session.getAttribute("readerIDList");
if (readerIDList != null && readerIDList.size() > 0) {
Iterator ior = readerIDList.iterator();
while (ior.hasNext()) {
ReaderBean nrb = new ReaderBean();
String ids = (String) ior.next();
StringTokenizer st = new StringTokenizer(ids, "#");
int i = 0;
int userID = 0;
int deptID = 0;
int positionID = 0;
while (st.hasMoreTokens()) {
if (i == 0)
userID = Integer.parseInt((String) st.nextElement());
else if (i == 1)
deptID = Integer.parseInt((String) st.nextElement());
else if (i == 2)
positionID =
Integer.parseInt((String) st.nextElement());
;
i++;
}
String userName =
((BeanUser) users.getUserByID(userID)).getUserName();
String deptName =
((BeanDepartment) departments.getDeptByID(deptID))
.getDepartmentName();
String positionName = getPosition(positions, positionID);
nrb.setUserID(userID);
nrb.setUserName(userName);
nrb.setDeptID(deptID);
nrb.setDeptName(deptName);
nrb.setPositionID(positionID);
nrb.setPositionName(positionName);
readerList.add(nrb);
}
/*ArrayList readerList = new ArrayList();
readerIDList = (ArrayList)session.getAttribute("readerIDList");
if (readerIDList != null && readerIDList.size() > 0) {
Iterator ior = readerIDList.iterator();
ArrayList readerNameList = new ArrayList();
String tmpStr = (String)session.getAttribute("readerNameStr");
if (tmpStr != null && !tmpStr.equals("")) {
StringTokenizer st = new StringTokenizer(tmpStr, "#");
while(st.hasMoreTokens()) {
readerNameList.add((String)st.nextElement());
}
}
Iterator ier = readerNameList.iterator();
while (ior.hasNext()) {
ReaderBean nrb = new ReaderBean();
int userID = Integer.parseInt((String)ior.next());
String readerStr = "";
if(ier.hasNext())
readerStr = (String)ier.next();
StringTokenizer st = new StringTokenizer(readerStr, "&&&&&&&&");
if(st.hasMoreTokens()) {
nrb.setUserName((String)st.nextElement());
nrb.setDeptName((String)st.nextElement());
}
String ststr = "";
if(st.hasMoreElements()) ststr = (String)st.nextElement();
StringTokenizer st1 = new StringTokenizer(ststr, "&&");
if(st1.hasMoreTokens()) {
nrb.setPositionName((String)st1.nextElement());
}
nrb.setUserID(userID);
readerList.add(nrb);
}*/
form.setReaderList(readerList);
form.setSelectedIDStr(null);
}
else
form.setReaderList(readerList);
return (mapping.findForward(FORWARD_Select));
}
/**
*
* @param mapping
* @param form
* @param request
* @throws Exception
* @return ActionForward
*/
public ActionForward doChangeGroup(ActionMapping mapping,
SelectReaderForm form,
HttpServletRequest request,
HttpServletResponse response,
User user)
throws Exception {
// Add your logic code here
HttpSession session = request.getSession();
CacheObjects objCacheObjects =
(CacheObjects) session.getServletContext().getAttribute(
DeInfoConstant.PLATFORM_CONTEXT);
CacheUsers users = objCacheObjects.getUsers();
CacheDepartments departments = objCacheObjects.getDepartments();
CachePositions positions = objCacheObjects.getPositions();
CacheGroups groups = objCacheObjects.getGroups();
String selGroupID = form.getSelGroupID();
String readerNameStr = form.getReaderNameStr();
//session.removeAttribute("readerNameStr");
session.setAttribute("readerNameStr", readerNameStr);
String[] tmpIDArray = form.getSelectedIDStr();
form.reset();
ArrayList readerIDList = new ArrayList();
if (tmpIDArray != null) {
for (int i = 0; i < tmpIDArray.length; i++) {
readerIDList.add(tmpIDArray[i]);
}
}
//session.removeAttribute("readerIDList");
session.setAttribute("readerIDList", readerIDList);
ArrayList empList = new ArrayList();
ArrayList tmpList = new ArrayList();
HashMap hm = new HashMap();
if (selGroupID == null
|| selGroupID.equals("")
|| selGroupID.equals("0")) {
form.setAction("Select");
return (mapping.findForward(FORWARD_Select));
}
if (selGroupID.equals("9998")) {
form.setEmpList(empList);
} else {
tmpList = users.getUsersByGroupID(Integer.parseInt(selGroupID));
Iterator it = tmpList.iterator();
while (it.hasNext()) {
BeanGroup bg = (BeanGroup) it.next();
int userID = bg.getUserID();
int deptID = bg.getDeptID();
//要排除用户组中用户重复的情况
if (userID == 0 && deptID == 0) { //所有用户都属于该用户组
ArrayList alist = users.getUsers();
Iterator ior = alist.iterator();
while (ior.hasNext()) {
BeanUser bu = (BeanUser) ior.next();
int uid = bu.getUserID();
String userName = users.getUserByID(uid).getUserName();
int did =
((BeanDepartment) (users
.getDeptsByUserID(uid)
.get(0)))
.getDeptID();
String departmentName =
((BeanDepartment) (users
.getDeptsByUserID(uid)
.get(0)))
.getDepartmentName();
int pid = users.getUserPosition(uid, did);
String positionName = getPosition(positions, pid);
ReaderBean rb = new ReaderBean();
rb.setUserID(uid);
rb.setUserName(userName);
rb.setDeptID(did);
rb.setDeptName(departmentName);
rb.setPositionID(pid);
rb.setPositionName(positionName);
hm.put(new Integer(uid), rb);
}
} else if (userID == 0 && deptID != 0) { //某部门下的所有用户属于该用户组
ArrayList alist = users.getUsersByDeptID(deptID);
Iterator irr = alist.iterator();
while (irr.hasNext()) {
BeanUser bu = (BeanUser) irr.next();
int uid = bu.getUserID();
String userName = users.getUserByID(uid).getUserName();
String departmentName =
((BeanDepartment) departments.getDeptByID(deptID))
.getDepartmentName();
int pid = users.getUserPosition(uid, deptID);
String positionName = getPosition(positions, pid);
ReaderBean rb = new ReaderBean();
rb.setUserID(uid);
rb.setUserName(userName);
rb.setDeptID(deptID);
rb.setDeptName(departmentName);
rb.setPositionID(pid);
rb.setPositionName(positionName);
hm.put(new Integer(uid), rb);
}
} else if (userID != 0) {
String userName = users.getUserByID(userID).getUserName();
String departmentName =
((BeanDepartment) departments.getDeptByID(deptID))
.getDepartmentName();
//log.error("开始取userID:" + userID + ",deptID:" + deptID + " 对应的positionID的值。");
int positionID = 0;
if (userID == 1) { //如果是系统管理员
positionID = 1; //直接设置其职务为代定
} else {
positionID = users.getUserPosition(userID, deptID);
}
//log.error("positionID:####" + positionID + "####");
String positionName = getPosition(positions, positionID);
ReaderBean rb = new ReaderBean();
rb.setUserID(userID);
rb.setUserName(userName);
rb.setDeptID(deptID);
rb.setDeptName(departmentName);
rb.setPositionID(positionID);
rb.setPositionName(positionName);
hm.put(new Integer(userID), rb);
}
}
}
empList.addAll(hm.values());
form.setEmpList(empList);
form.setSelGroupID(selGroupID);
form.setSelDeptID("9998");
ArrayList readerList = new ArrayList();
readerIDList = (ArrayList) session.getAttribute("readerIDList");
if (readerIDList != null && readerIDList.size() > 0) {
Iterator ior = readerIDList.iterator();
while (ior.hasNext()) {
ReaderBean nrb = new ReaderBean();
String ids = (String) ior.next();
StringTokenizer st = new StringTokenizer(ids, "#");
int i = 0;
int userID = 0;
int deptID = 0;
int positionID = 0;
while (st.hasMoreTokens()) {
if (i == 0)
userID = Integer.parseInt((String) st.nextElement());
else if (i == 1)
deptID = Integer.parseInt((String) st.nextElement());
else if (i == 2)
positionID =
Integer.parseInt((String) st.nextElement());
i++;
}
String userName =
((BeanUser) users.getUserByID(userID)).getUserName();
String deptName =
((BeanDepartment) departments.getDeptByID(deptID))
.getDepartmentName();
String positionName = getPosition(positions, positionID);
nrb.setUserID(userID);
nrb.setUserName(userName);
nrb.setDeptID(deptID);
nrb.setDeptName(deptName);
nrb.setPositionID(positionID);
nrb.setPositionName(positionName);
readerList.add(nrb);
}
/*ArrayList readerNameList = new ArrayList();
String tmpStr = (String)session.getAttribute("readerNameStr");
if (tmpStr != null && !tmpStr.equals("")) {
StringTokenizer st = new StringTokenizer(tmpStr, "#");
while(st.hasMoreTokens()) {
readerNameList.add((String)st.nextElement());
}
}
Iterator ier = readerNameList.iterator();
while (ior.hasNext()) {
ReaderBean nrb = new ReaderBean();
int userID = Integer.parseInt((String)ior.next());
String readerStr = (String)ier.next();
StringTokenizer st = new StringTokenizer(readerStr, "&&&&&&&&");
if(st.hasMoreTokens()) {
nrb.setUserName((String)st.nextElement());
nrb.setDeptName((String)st.nextElement());
}
StringTokenizer st1 = new StringTokenizer((String)st.nextElement(), "&&");
if(st1.hasMoreTokens()) {
nrb.setPositionName((String)st1.nextElement());
}
nrb.setUserID(userID);
readerList.add(nrb);
}*/
form.setReaderList(readerList);
form.setSelectedIDStr(null);
} else {
form.setReaderList(readerList);
form.setSelectedIDStr(null);
}
return (mapping.findForward(FORWARD_Select));
}
/**
*
* @param mapping
* @param form
* @param request
* @throws Exception
* @return ActionForward
*/
public ActionForward doSave(ActionMapping mapping,
SelectReaderForm form,
HttpServletRequest request,
HttpServletResponse response,
User user)
throws Exception {
// Add your logic code here
HttpSession session = request.getSession();
String readerNameStr = form.getReaderNameStr();
session.removeAttribute("readerNameStr");
setReaderID("ReaderIDs",mapping,form,request,response,user);
session.removeAttribute("readerIDList");
//}
return (mapping.findForward(FORWARD_Back));
}
/**
*
* @param mapping
* @param form
* @param request
* @throws Exception
* @return ActionForward
*/
public ActionForward doCancel(ActionMapping mapping,
SelectReaderForm form,
HttpServletRequest request,
HttpServletResponse response,
User user)
throws Exception {
log.debug("enter save:");
// Add your logic code here
HttpSession session = request.getSession();
String readerNameStr = form.getReaderNameStr();
session.removeAttribute("readerNameStr");
session.removeAttribute("readerIDList");
form.reset();
return (mapping.findForward(FORWARD_Back));
}
// add by weij;
/**
*
* @param mapping
* @param form
* @param request
* @throws Exception
* @return ActionForward
*/
public ActionForward doSave2(ActionMapping mapping,
SelectReaderForm form,
HttpServletRequest request,
HttpServletResponse response,
User user)
throws Exception {
// Add your logic code here
HttpSession session = request.getSession();
String readerNameStr = form.getReaderNameStr();
session.removeAttribute("readerNameStr");
setReaderID("ReaderIDs2",mapping,form,request,response,user);
session.removeAttribute("readerIDList");
//}
return (mapping.findForward(FORWARD_Back));
}
private String getPosition(CachePositions posts, int pid) {
String position = DEFAULT_POSITION;
BeanPosition bpost0 = (BeanPosition) posts.getPositionByID(pid);
if (bpost0 != null) {
position = bpost0.getPosition();
}
return position;
}
private boolean setReaderID(String attrName,
ActionMapping mapping,
SelectReaderForm form,
HttpServletRequest request,
HttpServletResponse response,
User user)
{
String[] tmpIDArray = form.getSelectedIDStr();
ArrayList readerIDList = new ArrayList();
if (tmpIDArray != null) {
for (int i = 0; i < tmpIDArray.length; i ++) {
readerIDList.add(tmpIDArray[i]);
log.debug("tmpIDArray[i]:"+tmpIDArray[i]);
}
}
if (readerIDList != null && readerIDList.size() > 0) {
ArrayList readerList = new ArrayList();
Iterator ior = readerIDList.iterator();
while (ior.hasNext()) {
ReaderBean nrb = new ReaderBean();
String ids = (String) ior.next();
log.debug("ids: "+ids);
StringTokenizer st = new StringTokenizer(ids, "#");
log.debug("StringTokenizer:"+st.toString());
int i = 0;
int userID = 0;
int deptID = 0;
int positionID = 0;
while (st.hasMoreTokens()) {
if (i == 0)
userID = Integer.parseInt((String) st.nextElement());
else if (i == 1)
deptID = Integer.parseInt((String) st.nextElement());
else if (i == 2)
positionID =
Integer.parseInt((String) st.nextElement());
;
i++;
}
log.debug("userid:"+userID);
readerList.add((new Integer(userID)).toString());
}
System.out.println("arrname:"+attrName);
HttpSession session = request.getSession();
session.setAttribute(attrName,readerList);
if(readerList!=null)
System.out.println("readerList.size:"+readerList.size());
else
System.out.println("readerList is null!!!");
}
return true;
}
}
相关推荐
一、ERA5数据下载,deepseek提问全图
UE5 MQTT通信插件
【vue】基于 Vue3 + Element Plus 实现,支持 RBAC 动态权限、数据权限、SaaS 多租户、Flowable 工作流、三方登录、支付、短信、商城、CRM 等功能_pgj
1.版本:matlab2014/2019a/2024a 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。
该项目为基于C#语言的智能诊断交付系统插件设计源码,总计包含122个文件,涉及多种类型,包括70个元数据文件、26个C#源代码文件、6个预制体文件、5个材质文件、3个着色器文件、3个Unity脚本文件、2个汇编定义文件、1个Cginc文件、1个Markdown文件、1个光照文件。该系统专注于智能诊断交付,旨在提升诊断交付的效率和准确性。
内容概要:本文探讨了一个经典的数组操作问题——在一个已经排序的数组中去除多余的重复元素,确保每个元素最多出现两次。该问题要求算法在原地执行(不引入新的数据结构),并且仅消耗O(1)的额外存储空间。文中详细展示了问题的要求与挑战,给出具体的示例帮助理解,并明确指出了解题思路和预期效果。 适用人群:面向有一定编程经验的学习者或者初涉Python开发的语言爱好者,尤其是对算法有兴趣的人群。 使用场景及目标:适用于那些希望提升自己数据处理技巧,特别是有关列表、数组的操作技能的人。该方法可以在内存有限的情况下进行高效的去重处理,比如嵌入式系统或者大规模数据分析环境。 其他说明:该算法主要运用双指针(快慢指针)的方法,在遍历数组的同时实现对原始数据的部分覆盖来达到减少重复项目的目的,同时也提醒使用者注意'引用'特性可能引起的潜在误解。
1.版本:matlab2014/2019a/2024a 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。
深海沉积物岩心GeoB17603-2的文档记录 内容 该文献由Lucchi RG、Sabbatini A、Nicolaisen LS等人于2014年发布,主要描述了深海沉积物岩心GeoB17603-2的相关信息。具体内容涉及岩心的采集情况及其详细特征等。读者可通过访问"此链接" ()获取更多关于该数据集的信息。遗憾的是,目前尚未提供该数据集的具体大小。
本项目为Node.js学习资源集,包含41个文件,涵盖26个JavaScript文件、4个HTML文件、3个JSON文件、3个文本文件、2个Markdown文件、1个Git忽略文件、1个PNG图像文件、1个TypeScript文件。内容丰富,涉及Node.js学习的各个方面,旨在帮助开发者掌握相关技能。
1.版本:matlab2014/2019a/2024a 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。
1.版本:matlab2014/2019a/2024a 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。
本项目是一个基于Vue框架和JavaScript的前端样式设计源码,专注于实现图片对比效果,通过input range控件实现风格切换。该项目包含87个文件,其中SVG文件48个,JavaScript文件16个,Vue文件8个,JPG图片文件5个,JSON文件3个,开发配置文件1个,生产配置文件1个,Git忽略文件1个,Markdown文件1个,HTML文件1个。项目适用于需要展示和比较不同图片风格的场景。
MAX30102心率血样传感器原理图
资源名称:Python—Excel选表头列key-value-转json文件 类型:windows—exe可执行工具 环境:Windows10或以上系统 功能: 1. 点击按钮【选择文件】:选择一个Exel文件(默认第一行为表头) 2. 点击选择key列(可多选-多个中间用“=”隔开) 3. 点击选择value列(可多选-多个中间用“=”隔开) 4. 点击按钮【选择文件】:保存路径 5. 点击按钮【转换并保存】:保存路径 优点: 1、非常快的速度! 2、已打包—双击即用!无需安装! 3、自带GUI界面方便使用!
该项目是一个个人作品集设计源码,采用HTML、JavaScript和CSS技术构建,包含50个文件,其中包括12个HTML文件、10个JavaScript文件、9个JPG图片文件、6个PNG图片文件、4个CSS样式表文件、3个SVG矢量图形文件、以及各种字体文件,如EOT、TTF、WOFF和WOFF2等。该作品集旨在展示个人设计作品,适合个人网站或在线展示使用。
该项目是一款基于C语言核心开发,并融合HTML、CSS、Python等多语言技术的智能仓储安防控制系统源码。项目包含360个文件,其中225个为头文件(.h),32个为C语言源文件(.c),27个为压缩文件(.gz),8个为共享库文件(.so),7个为静态库文件(.a),6个为配置文件(.1, .pc, .cmake)和3个XML文件(.xml)。该系统旨在提供智能化的仓储安防解决方案。
鱼码grant.dll是一个简单易用的标准DLL,让软件开发者快速为自己软件加上注册码,支持在线和离线授权,实现商用授权许可。鱼码可以让开发者快速为自己软件加上软件升级功能 软件托管,0成本搭建平台,在线销售自己软件,管理授权码。 dll使用说明可进入演示地址进行查看。 安装: 1、下载dll注册成开发者 2、调用dll里check_grant函数 3、会员中心管理自己授权码发放或过期、删除等操作 软件有vb、vb.net、vc、vc.net、易语言和Delphi示例,压缩包中的为vb.net的,如果需要其他版本的demo请到官网进行下载。
乡村小道图像分割系统:智能化检测
内容概要:本文介绍了新碧彩SaaS平台项目的特点及其建设优势。新碧彩SaaS平台采用了云托管方式部署,利用微服务架构进行业务拓展,统一接口管理和多租户模式以降低运营成本、提高灵活性。通过集群部署及专业的运维团队,保障租户使用的稳定性、安全性、高效率。平台实现了采购业务全流程的规范化管理及优化。同时支持快速扩展各类业务应用,包括财务管理、办公自动化、人力资源等多个方面。 适合人群:对于物业公司或其他相关行业的技术人员、管理者及关注企业数字化转型的从业者。 使用场景及目标:①解决现有采购管理系统难以适应快速增长的企业规模和发展需求的问题;②通过引入新技术提升管理水平和服务质量;③实现业务处理流程化、数据化的目标,并能轻松对接第三方服务商的数据接口服务。 其他说明:本文详细阐述了如何借助现代化信息技术手段,助力企业转型升级为智能型企业,特别是在当前中国物业管理市场背景下尤为重要。此外还提到平台未来可能会继续围绕用户体验改进功能特性,如提供更多增值服务等。
该项目为基于Java开发的在线书城设计源码,包含55个文件,涵盖41个Java源文件、10个XML配置文件、2个Git忽略文件、1个YAML文件和1个TXT文件。