示例#1
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");
    }
  }