Example #1
0
 /**
  * 删除内存中的对象的公用方法
  *
  * @param delIdS
  * @param custNo
  * @param sessCustNo
  * @param sessConstant
  * @throws ClassNotFoundException
  * @throws IllegalAccessException
  * @throws InstantiationException
  */
 @SuppressWarnings("unchecked")
 public void deleteSessionObj(
     String delIdS,
     int custNo,
     String sessCustNo,
     SessionConstant sessConstant,
     String className) {
   String delIdStr = ServletActionContext.getRequest().getParameter(delIdS);
   System.out.println("delIdStr: " + delIdStr);
   if (StringUtils.isNotEmpty(delIdStr)) {
     String[] strs = delIdStr.split(",");
     List<String> delIdList = Arrays.asList(strs);
     Map<String, Object> map = null;
     // 取得session中的map
     System.out.println("custNo, sessCustNo: " + custNo + ", " + sessCustNo);
     map = SessionUtil.getRow(sessConstant.value(), custNo, sessCustNo);
     System.out.println("Map; " + map);
     if (map == null) {
       map = new HashMap<String, Object>();
     }
     for (String str : delIdList) {
       if (StringUtils.isNumeric(str)) {
         if (map != null && map.containsKey(str)) {
           T dto = (T) map.get(str);
           dto.setOperationType(OperationType.DEL);
           map.put(str, dto);
         } else {
           T dto = null;
           try {
             dto = (T) Class.forName(className).newInstance();
           } catch (InstantiationException e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
           } catch (IllegalAccessException e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
           } catch (ClassNotFoundException e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
           }
           dto.setOperationType(OperationType.DEL);
           map.put(str, dto);
         }
       } else {
         map.remove(str);
       }
     }
     System.out.println("map: " + map);
     SessionUtil.insertRow(sessConstant.value(), custNo, sessCustNo, map);
   }
 }