/**
   * 根据URL参数执行 toCustinfoLoad 方法,返回要forward页面。 并且根据URL参数中type的值来判断所执行的操作:CRUD
   *
   * @param ActionMapping
   * @param ActionForm
   * @param HttpServletRequest
   * @param HttpServletResponse
   * @return ActionForward 返回列表页面
   */
  public ActionForward toCustinfoLoad(
      ActionMapping map,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response) {

    String type = request.getParameter("type");
    request.setAttribute("opertype", type);

    List sexList = cts.getLabelVaList("custSex");
    request.setAttribute("sexList", sexList);

    List typeList = cts.getLabelVaList("custType");
    request.setAttribute("typeList", typeList);

    // 根本type参数判断执行所需要的操作
    if (type.equals("insert")) {

      // request.setAttribute(map.getName(),dto);
      return map.findForward("load");
    }

    if (type.equals("detail")) {

      String id = request.getParameter("id");
      IBaseDTO dto = custinfoService.getCustinfoInfo(id);
      request.setAttribute(map.getName(), dto);
      return map.findForward("load");
    }

    if (type.equals("update")) {

      request.setAttribute("opertype", "update");
      String id = request.getParameter("id");
      IBaseDTO dto = custinfoService.getCustinfoInfo(id);
      request.setAttribute(map.getName(), dto);
      return map.findForward("load");
    }
    if (type.equals("delete")) {

      String id = request.getParameter("id");
      IBaseDTO dto = custinfoService.getCustinfoInfo(id);
      request.setAttribute(map.getName(), dto);
      return map.findForward("load");
    }

    return map.findForward("load");
  }
Пример #2
0
  protected XWikiContext initializeXWikiContext(
      ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse resp)
      throws XWikiException, ServletException {
    String action = mapping.getName();

    XWikiRequest request = new XWikiServletRequest(req);
    XWikiResponse response = new XWikiServletResponse(resp);
    XWikiContext context =
        Utils.prepareContext(
            action, request, response, new XWikiServletContext(this.servlet.getServletContext()));

    // This code is already called by struts.
    // However struts will also set all the parameters of the form data
    // directly from the request objects.
    // However because of bug http://jira.xwiki.org/jira/browse/XWIKI-2422
    // We need to perform encoding of windows-1252 chars in ISO mode
    // So we need to make sure this code is called
    // TODO: completely get rid of struts so that we control this part of the code and can reduce
    // drastically the
    // number of calls
    if (form != null) {
      form.reset(mapping, request);
    }

    // Add the form to the context
    context.setForm((XWikiForm) form);

    // Initialize the Container component which is the new way of transporting the Context in the
    // new
    // component architecture.
    initializeContainerComponent(context);

    return context;
  }
Пример #3
0
 private ActionForm createNewActionForm(ActionMapping mapping, HttpServletRequest request) {
   String name = mapping.getName();
   FormBeanConfig config = moduleConfig.findFormBeanConfig(name);
   if (config == null) {
     log.warn("No FormBeanConfig found under '" + name + "'");
     return (null);
   }
   ActionForm instance = RequestUtils.createActionForm(config, servlet);
   if ("request".equals(mapping.getScope())) {
     request.setAttribute(mapping.getAttribute(), instance);
   } else {
     HttpSession session = request.getSession();
     session.setAttribute(mapping.getAttribute(), instance);
   }
   return instance;
 }
Пример #4
0
  private void mappingContextAppend(HttpServletRequest request, final StringBuilder exceptionInfo) {
    String query = request.getQueryString();
    setRequestURI(request.getRequestURI());
    setRequestURL(request.getRequestURL().toString());
    setRequestFullUrl(getRequestFullUrl(request));
    setQueryString(query);
    setRequestMethod(request.getMethod());
    setRequestParameters(getRequestParameters(request));
    exceptionInfo.append("[RequestURI] ").append(request.getRequestURI()).append("\n");
    exceptionInfo.append("[RequestURL] ").append(request.getRequestURL()).append("\n");
    exceptionInfo.append("[QueryString] ").append(request.getQueryString()).append("\n");
    exceptionInfo.append("[Method] ").append(request.getMethod()).append('\n');

    if (request.getAttribute(PresentationConstants.ORIGINAL_MAPPING_KEY) != null) {
      ActionMapping mapping =
          (ActionMapping) request.getAttribute(PresentationConstants.ORIGINAL_MAPPING_KEY);
      setActionMapping(mapping);
      exceptionInfo.append("[Path] ").append(mapping.getPath()).append("\n");
      exceptionInfo.append("[Name] ").append(mapping.getName()).append("\n");
    } else {
      exceptionInfo.append(
          "[Path|Name] impossible to get (exception through UncaughtExceptionFilter)\n");
    }
  }