示例#1
0
  /**
   * 设置进入增加页面的初始值
   *
   * @param actionForm ActionForm 表单From
   * @param request HttpServletRequest Web请求
   * @param response HttpServletResponse Web结果
   * @throws CDealException 处理异常
   */
  public static void setAddDefault(
      AddForm aWebForm, HttpServletRequest request, HttpServletResponse response)
      throws CDealException {
    try {
      // 初始化页面,初始化法律类别下拉菜单
      TreeMap classificationList = new TreeMap();
      classificationList = CCodeMap.getMapByType("法律类别");
      aWebForm.setClassificationList(classificationList);
      CLog.println("\n法律类别");
      // 初始化页面,初始化业务类别下拉菜单
      TreeMap businesstypeList = new TreeMap();
      businesstypeList = CCodeMap.getMapByType("法律法规业务类别");
      aWebForm.setBusinesstypeList(businesstypeList);
      CLog.println("\n法律法规业务类别");

    } catch (Exception e) {
      throw new CDealException("进入增加" + mModuleName + "时失败。", e);
    }
  }
示例#2
0
  /**
   * 响应页面提交
   *
   * @param actionMapping ActionMapping 这个 Action 的配置信息
   * @param actionForm ActionForm 用户提交的表单数据
   * @param request HttpServletRequest 当前的 HTTP 请求对象
   * @param response HttpServletResponse 当前的 HTTP 响应对象
   * @return ActionForward 请求转发路径
   * @throws Exception
   */
  public ActionForward execute(
      ActionMapping actionMapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    AddForm aWebForm = (AddForm) actionForm;

    if (aWebForm.getMethod() == null) { // 初次进行页面,需要取初始值
      Deal.setAddDefault(aWebForm, request, response); // 设置进入增加页面的初始值
      return actionMapping.getInputForward();
    } else {
      String sMessage = "未能找到 " + aWebForm.getMethod() + " 对应的处理方法";
      String[] button; // 按钮数组
      String[] onclick; // 按钮响应事件
      if (aWebForm.getMethod().equals("do_save")) { // 增加
        String EVENTID = Deal.doAdd(aWebForm, request, response); // 处理增加
        int EVENTBIGTYPE = aWebForm.getTYWyjyasendevent().getEVENTBIGTYPE();
        int EVENTSMALLTYPE = aWebForm.getTYWyjyasendevent().getEVENTSMALLTYPE();
        sMessage = "增加" + mModuleName + "处理成功";
        button = new String[] {"返回", "关闭"}; // 按钮数组
        onclick =
            new String[] {
              "window.location='/lh/business/yjya/ywyabs/edit.TJ?BS=YES&EVENTID="
                  + EVENTID
                  + "&EVENTBIGTYPE="
                  + EVENTBIGTYPE
                  + "&EVENTSMALLTYPE="
                  + EVENTSMALLTYPE
                  + "'",
              "parent.window.close()"
            }; // 按钮响应事件

      } else if (aWebForm.getMethod().equals("do_submit")) { // 提交
        Deal.doAdd_submit(aWebForm, request, response); // 处理提交
        sMessage = "提交到接收成功";
        button = new String[] {"关闭"}; // 按钮数组
        onclick = new String[] {"parent.window.close()"}; // 按钮响应事件
      } else { // 未能找到 " + aWebForm.getMethod() + " 对应的处理方法
        button = new String[] {"关闭"}; // 按钮数组
        onclick = new String[] {"parent.window.close()"}; // 按钮响应事件
      }

      CCommonMessage mMessage = new CCommonMessage(); // 统一提示页面
      mMessage.setMessage(sMessage); // 默认为"处理成功!"
      //      String[] button = {"关闭"};  // 按钮数组
      //      String[] onclick = {"parent.window.close()"};  // 按钮响应事件
      mMessage.setButtonName(button);
      mMessage.setOnClickFunc(onclick);
      request.setAttribute(CConstants.MESSAGE_OBJECT, mMessage);
      // 在处理页面最后调用(事先要配置名字为success的forward,在全局配置里有 message)
      return actionMapping.findForward("message");
    }
  }
示例#3
0
  /**
   * 响应页面提交
   *
   * @param actionMapping ActionMapping 这个 Action 的配置信息
   * @param actionForm ActionForm 用户提交的表单数据
   * @param request HttpServletRequest 当前的 HTTP 请求对象
   * @param response HttpServletResponse 当前的 HTTP 响应对象
   * @return ActionForward 请求转发路径
   * @throws Exception
   */
  public ActionForward execute(
      ActionMapping actionMapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    AddForm aWebForm = (AddForm) actionForm;
    if (aWebForm.getMethod() == null) { // 初次进行页面,需要取初始值
      Deal.setAddDefault(aWebForm, request, response); // 设置进入增加页面的初始值
      return actionMapping.getInputForward();
    } else {
      String sMessage = "未能找到 " + aWebForm.getMethod() + " 对应的处理方法";
      String[] button; // 按钮数组
      String[] onclick; // 按钮响应事件
      if (aWebForm.getMethod().equals("add")) { // 增加
        String id = Deal.doSave(aWebForm, request, response); // 处理增加
        sMessage = "增加" + mModuleName + "处理成功";
        button = new String[] {"返回", "关闭"}; // 按钮数组
        onclick =
            new String[] {
              "window.location='/lh/business/newxzzf/rypzk/edit.TJ?BS=YES&BBM=1&ID=" + id + "'",
              "parent.window.close()"
            }; // 按钮响应事件
      } else { // 未能找到 " + aWebForm.getMethod() + " 对应的处理方法
        button = new String[] {"关闭"}; // 按钮数组
        onclick = new String[] {"parent.window.close()"}; // 按钮响应事件
      }

      CCommonMessage mMessage = new CCommonMessage(); // 统一提示页面
      mMessage.setMessage(sMessage); // 默认为"处理成功!"
      mMessage.setButtonName(button);
      mMessage.setOnClickFunc(onclick);
      request.setAttribute(CConstants.MESSAGE_OBJECT, mMessage);
      // 在处理页面最后调用(事先要配置名字为success的forward,在全局配置里有 message)
      return actionMapping.findForward("message");
    }
  }
示例#4
0
  /**
   * 将页面的Form的数据拷内到实体对象
   *
   * @param aWebForm TPubGgl 页面的Form
   * @return editForm 法律法规管理增加的form
   * @throws Exception
   */
  private static TPubFlfggl webForm2PoForm(AddForm aWebForm) throws Exception {
    TPubFlfggl aPoBean = new TPubFlfggl();
    aPoBean.setId(aWebForm.getTPubFlfggl().getId());
    aPoBean.setTitle(aWebForm.getTPubFlfggl().getTitle());
    aPoBean.setClassification(aWebForm.getTPubFlfggl().getClassification());
    aPoBean.setBusinesstype(aWebForm.getTPubFlfggl().getBusinesstype());
    aPoBean.setIssuedate(
        CTools.convertStringToTimestamp(aWebForm.getTPubFlfggl().getIssueTime_str(), "yyyy-MM-dd"));
    aPoBean.setCreatetime(
        CTools.convertStringToTimestamp(
            aWebForm.getTPubFlfggl().getCreateTime_str(), "yyyy-MM-dd"));
    aPoBean.setOrderno(aWebForm.getTPubFlfggl().getOrderno());
    aPoBean.setContent(aWebForm.getTPubFlfggl().getContent());
    aPoBean.setSpare1(aWebForm.getTPubFlfggl().getSpare1());
    aPoBean.setSpare2(aWebForm.getTPubFlfggl().getSpare2());
    aPoBean.setSpare3(aWebForm.getTPubFlfggl().getSpare3());
    aPoBean.setSpare4(aWebForm.getTPubFlfggl().getSpare4());

    return aPoBean;
  }
示例#5
0
 /**
  * 处理增加
  *
  * @param actionForm ActionForm 表单From
  * @param request HttpServletRequest Web请求
  * @param response HttpServletResponse Web结果
  * @throws CDealException 处理异常
  */
 public static long doAdd(
     AddForm pWebForm, HttpServletRequest request, HttpServletResponse response)
     throws CDealException, SQLException {
   long chapterid;
   Connection mconn = null;
   PreparedStatement pstmt = null;
   try {
     CUserBean loginUser =
         (CUserBean) request.getSession().getAttribute(CConstants.USER_BEAN); // 用户BEAN
     /*TPubFlfggl aPoBean = webForm2PoForm(pWebForm);  // 将页面的Form的数据拷内到实体对象
     aPoBean.setId(CTools.getNewNumID());
     aPoBean.setCreateperson(loginUser.getId());  // 用户 ID
     aPoBean.setCreatetime(CTools.getCurrentTimestamp());  // 当前时间
     CHibernateUtil.saveObject(aPoBean);  // 调用 PO 层进行增加 */
     chapterid = CTools.getNewNumID();
     mconn = CDBManager.getConn();
     mconn.setAutoCommit(false); // 将自动提交设置为否
     String sql =
         "insert into t_pub_law (id,createperson,createtime,title,classification,issuedate,orderno,spare1,spare2,spare3,spare4,businesstype,bigcontent) values(?,?,?,?,?,?,?,?,?,?,?,?,?)";
     pstmt = mconn.prepareStatement(sql);
     pstmt.setLong(1, chapterid);
     pstmt.setLong(2, loginUser.getId());
     pstmt.setTimestamp(3, CTools.getCurrentTimestamp());
     pstmt.setString(4, pWebForm.getTPubFlfggl().getTitle());
     CLog.println("4====title=" + pWebForm.getTPubFlfggl().getTitle());
     pstmt.setInt(5, pWebForm.getTPubFlfggl().getClassification());
     CLog.println("5====classification=" + pWebForm.getTPubFlfggl().getClassification());
     pstmt.setTimestamp(
         6,
         CTools.convertStringToTimestamp(
             pWebForm.getTPubFlfggl().getIssueTime_str(), "yyyy-mm-dd"));
     pstmt.setLong(7, pWebForm.getTPubFlfggl().getOrderno());
     pstmt.setString(8, pWebForm.getTPubFlfggl().getSpare1());
     pstmt.setString(9, pWebForm.getTPubFlfggl().getSpare2());
     pstmt.setString(10, pWebForm.getTPubFlfggl().getSpare3());
     pstmt.setString(11, pWebForm.getTPubFlfggl().getSpare4());
     pstmt.setInt(12, pWebForm.getTPubFlfggl().getBusinesstype());
     pstmt.setClob(13, CLOB.empty_lob()); // 构造空CLOB对象
     pstmt.executeUpdate();
     pstmt.close();
     // =======================再次从库表中读出,获得CLOB句柄
     pstmt =
         mconn.prepareStatement("select a.bigcontent from t_pub_law a where a.id = ? for update");
     pstmt.setLong(1, chapterid);
     ResultSet rs = pstmt.executeQuery();
     rs.next();
     CLOB textClob = (CLOB) rs.getClob(1);
     textClob.putString(
         1,
         pWebForm
             .getTPubFlfggl()
             .getBigContent_str()
             .replaceAll("\n", "<br>")); // 将页面的法律法规内容写入Clob
     pstmt = mconn.prepareStatement("update t_pub_law set bigcontent=? where id=?");
     pstmt.setClob(1, textClob);
     pstmt.setLong(2, chapterid);
     pstmt.executeUpdate();
     return chapterid;
   } catch (Exception e) {
     throw new CDealException("执行增加" + mModuleName + "时失败。", e);
   } finally {
     if (pstmt != null) {
       pstmt.close();
     }
     mconn.commit();
     if (mconn != null) {
       mconn.close();
     }
   }
 }