`
microsystems
  • 浏览: 7209 次
最近访客 更多访客>>
社区版块
存档分类
最新评论

SelectReaderAction

阅读更多
/*

* 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;
       
    }


}
分享到:
评论

相关推荐

    python入门-30.寻找列表中只出现一次的数字-寻找单身狗.py

    python入门-30.寻找列表中只出现一次的数字——寻找单身狗.py

    布尔教育linux优化笔记

    linux优化笔记,配套视频:https://www.bilibili.com/list/474327672?sid=4496133&spm_id_from=333.999.0.0&desc=1

    知识付费系统-直播+讲师入驻+课程售卖+商城系统-v2.1.9版本搭建以及资源分享下载

    知识付费系统-直播+讲师入驻+课程售卖+商城系统-v2.1.9版本搭建以及资源分享下载,CRMEB知识付费分销与直播营销系统是由西安众邦科技自主开发的一款在线教育平台,该系统不仅拥有独立的知识产权,还采用了先进的ThinkPhp5.0框架和Vue前端技术栈,集成了在线直播教学及课程分销等多种功能,旨在为用户提供全方位的学习体验,默认解压密码youyacaocom

    美妆神域-JAVA-基于springBoot美妆神域设计与实现

    美妆神域-JAVA-基于springBoot美妆神域设计与实现

    原生js制作Google粘土logo动画涂鸦代码.zip

    原生js制作Google粘土logo动画涂鸦代码.zip

    golin 扫描工具使用, 检查系统漏洞、web程序漏洞

    golin 扫描工具使用, 检查系统漏洞、web程序漏洞

    原生态纯js图片网格鼠标悬停放大显示特效代码下载.zip

    原生态纯js图片网格鼠标悬停放大显示特效代码下载.zip

    用AWLUM进行灰色编码2^2n-QAM调制的精确率Matlab代码.rar

    1.版本:matlab2014/2019a/2024a 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。 替换数据可以直接使用,注释清楚,适合新手

    去水印web端独立版web

    去水印web端独立版web

    原生js制作左侧浮动可折叠在线客服代码.zip

    原生js制作左侧浮动可折叠在线客服代码.zip

    Chrome 谷歌浏览器下载

    Chrome 谷歌浏览器下载

    亲测全新完整版H5商城系统源码 附教程

    全新完整版H5商城系统源码 自己花钱买的,亲测可用,需要自行下载 H5商城系统设置是实现商城基本功能的核心部分,涵盖了从网站配置、短信和支付配置,到商品、工单、订单、分站和提现管理等多个模块的设置。以下是详细的设置指南,帮助您快速上手并高效管理商城系统。 测试环境:Nginx+PHP7.0+MySQL5.6 1. 网站配置 设置商城名称、LOGO、标题、联系方式和SEO关键词等,确保商城专业和易于搜索。 2. 短信配置 配置短信接口和模板,用于发送订单通知、验证码等,提升用户体验。 3. 支付接口配置 配置微信、支付宝等支付接口,填写API密钥和回调地址,确保支付流畅。 4. 商品分类管理 对商品进行分类和排序,设置分类名称和图标,便于用户查找商品。 5. 商品管理 添加和管理商品信息、规格、图片等,确保商品信息准确丰富。 6. 工单管理 查看和回复用户工单,记录售后问题,提升用户服务质量。 7. 订单管理 查看订单详情,更新订单状态,支持批量导出,方便订单跟踪。 8. 分站管理 创建不同区域分站,设置权限,统一管理各区域市场。 9. 提现管理

    短信3.141592672893982398674234

    apk安装包

    原生js选项卡插件自定义图片滑动选项卡切换.zip

    原生js选项卡插件自定义图片滑动选项卡切换.zip

    1-宗教信息佛教佛寺寺庙庵堂相关数据-社科数据.zip

    宗教信息佛教佛寺寺庙庵堂相关数据集提供了全国各个地区省市县各个佛教寺庙的详细信息。这些数据不仅包括寺庙的名称和负责人姓名,还涵盖了所属省份、地级市、区县、具体地址、建立日期以及支派类别等关键信息。该数据集整理了超过3万条样本,为研究中国佛教寺庙的分布、历史和文化提供了丰富的第一手资料。这些信息有助于了解佛教在中国的传播和发展,以及寺庙在社会和文化中的作用。数据的整理和提供,对于宗教学、社会学、历史学和文化研究等领域的学者来说,是一个宝贵的资源。

    线性电阻网络的等效电阻计算Matlab代码.rar

    1.版本:matlab2014/2019a/2024a 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。 替换数据可以直接使用,注释清楚,适合新手

    简单的 Python 版本管理.zip

    简单的 Python 版本管理pyenvpyenv 可让您轻松在多个 Python 版本之间切换。它简单、不引人注目,并遵循 UNIX 传统,即使用单一用途的工具来做好一件事。该项目由rbenv和 ruby​​-build分叉而来,并针对 Python 进行了修改。pyenv 的作用是什么......允许您根据每个用户更改全局 Python 版本。为每个项目的 Python 版本提供支持。允许您使用环境变量覆盖 Python 版本。一次搜索多个 Python 版本的命令。这可能有助于使用tox跨 Python 版本进行测试。与 pythonbrew 和 pythonz 相比,pyenv没有……依赖于Python本身。pyenv由纯shell脚本制作。不存在Python的引导问题。需要加载到你的 shell 中。相反,pyenv 的 shim 方法通过向你的 中添加目录来工作PATH。管理虚拟环境。当然,你可以自己创建虚拟环境 ,或者使用pyenv-virtualenv 来自动化该过程。目录安装获取 PyenvLinux/UNIX自动安装程序基本

    Notepad-v2.20工具,是替代Notepad++的首选工具

    Notepad-v2.20工具,是替代Notepad++的首选工具

    原生js随机图片拖拽排序代码.zip

    原生js随机图片拖拽排序代码.zip

    更快、更好、更稳定的Redis桌面(GUI)管理客户端,兼容Windows、Mac、Linux,性能出众,轻松加载海量键值

    更快、更好、更稳定的Redis桌面(GUI)管理客户端,兼容Windows、Mac、Linux,性能出众,轻松加载海量键值

Global site tag (gtag.js) - Google Analytics