Package com.opensymphony.xwork2.config.entities

Examples of com.opensymphony.xwork2.config.entities.ResultConfig


   * @param extraParams
   * @return
   */
  protected Result buildResult(String resultCode, ResultTypeConfig resultTypeConfig, ActionContext context,
      Map<String, String> params) {
    ResultConfig resultConfig = new ResultConfig.Builder(resultCode, resultTypeConfig.getClassName())
        .addParams(params).build();
    try {
      return objectFactory.buildResult(resultConfig, context.getContextMap());
    } catch (Exception e) {
      throw new XWorkException("Unable to build convention result", e, resultConfig);
View Full Code Here


      method = conditionalParse(method, invocation);
    }

    String resultCode = invocation.getResultCode();
    if (resultCode != null) {
      ResultConfig resultConfig = invocation.getProxy().getConfig().getResults().get(resultCode);
      Map resultConfigParams = resultConfig.getParams();
      for (Iterator i = resultConfigParams.entrySet().iterator(); i.hasNext();) {
        Map.Entry e = (Map.Entry) i.next();
        if (!prohibitedResultParam.contains(e.getKey())) {
          requestParameters.put(e.getKey().toString(), e.getValue() == null ? "" : conditionalParse(e
              .getValue().toString(), invocation));
View Full Code Here

        Map<String,String> params = replaceParameters(orig.getParams(), vars);

        Map<String,ResultConfig> results = new LinkedHashMap<String,ResultConfig>();
        for (String name : orig.getResults().keySet()) {
            ResultConfig result = orig.getResults().get(name);
            name = convertParam(name, vars);
            ResultConfig r = new ResultConfig.Builder(name, convertParam(result.getClassName(), vars))
                    .addParams(replaceParameters(result.getParams(), vars))
                    .build();
            results.put(name, r);
        }
View Full Code Here

        PackageConfig packageConfig = createPackageConfigBuilder("/namespace");
        this.conventionsService = new ConventionsServiceImpl("/WEB-INF/location");
        DefaultResultMapBuilder builder = new DefaultResultMapBuilder(context, container, "dispatcher,velocity,freemarker");
        Action actionAnn = OverrideResultAction.class.getMethod("execute").getAnnotation(Action.class);
        Map<String, ResultConfig> results = builder.build(OverrideResultAction.class, actionAnn, "action100", packageConfig);
        ResultConfig result = results.get("error");
        assertNotNull(result);
        assertEquals("/WEB-INF/location/namespace/error-overriden.jsp", result.getParams().get("location"));
    }
View Full Code Here

        this.conventionsService = new ConventionsServiceImpl("/WEB-INF/location");
        DefaultResultMapBuilder builder = new DefaultResultMapBuilder(context, container, "dispatcher,velocity,freemarker");

        ResultTypeConfig resultType = new ResultTypeConfig.Builder("dispatcher", ServletDispatcherResult.class.getName()).
                addParam("key", "value").addParam("key1", "value1").defaultResultParam("location").build();
        ResultConfig globalError = new ResultConfig.Builder("error", ServletDispatcherResult.class.getName()).
                addParam("location", "/globalError.jsp").
                build();
        PackageConfig packageConfig = new PackageConfig.Builder("package").
                namespace("/namespace").
                defaultResultType("dispatcher").
                addResultTypeConfig(resultType).
                addGlobalResultConfig(globalError).
                build();


        Map<String, ResultConfig> results = builder.build(GlobalResultAction.class, null, "action", packageConfig);
        ResultConfig result = results.get("error");
        assertNotNull(result);
        assertEquals("/globalError.jsp", result.getParams().get("location"));
    }
View Full Code Here

        this.conventionsService = new ConventionsServiceImpl("/WEB-INF/location");
        DefaultResultMapBuilder builder = new DefaultResultMapBuilder(context, container, "dispatcher,velocity,freemarker");

        ResultTypeConfig resultType = new ResultTypeConfig.Builder("dispatcher", ServletDispatcherResult.class.getName()).
                addParam("key", "value").addParam("key1", "value1").defaultResultParam("location").build();
        ResultConfig globalError = new ResultConfig.Builder("error", ServletDispatcherResult.class.getName()).
                addParam("location", "/globalError.jsp").
                build();
        PackageConfig packageConfig = new PackageConfig.Builder("package").
                namespace("/namespace").
                defaultResultType("dispatcher").
                addResultTypeConfig(resultType).
                addGlobalResultConfig(globalError).
                build();


        Map<String, ResultConfig> results = builder.build(GlobalResultOverrideAction.class, null, "action", packageConfig);
        ResultConfig result = results.get("error");
        assertNotNull(result);
        assertEquals(resultPath + "/namespace/action-error.jsp", result.getParams().get("location"));
    }
View Full Code Here

        return assertClass("", action_name, class_name);
    }

    protected void assertResult(ActionConfig config, String result_name, String result_value) {
        Map results = config.getResults();
        ResultConfig result = (ResultConfig) results.get(result_name);
        Map params = result.getParams();
        String value = (String) params.get("actionName");
        if (value == null)
            value = (String) params.get("location");
        assertTrue("Wrong result value: [" + value + "]",
                result_value.equals(value));
View Full Code Here

        responseMock.verify();
    }

    public void testIncludeParameterInResult() throws Exception {

        ResultConfig resultConfig = new ResultConfig.Builder("", "")
            .addParam("namespace", "someNamespace")
            .addParam("encode", "true")
            .addParam("parse", "true")
            .addParam("location", "someLocation")
            .addParam("prependServletContext", "true")
View Full Code Here

        responseMock = new Mock(HttpServletResponse.class);

        requestMock = new Mock(HttpServletRequest.class);
        requestMock.matchAndReturn("getContextPath", "/context");

         ResultConfig resultConfig = new ResultConfig.Builder("", "").build();

        Map<String, ResultConfig> results=  new HashMap<String, ResultConfig>();
        results.put("myResult", resultConfig);

        ActionConfig actionConfig = new ActionConfig.Builder("", "", "")
View Full Code Here

        StrutsResultFactory builder = (StrutsResultFactory) container.getInstance(ResultFactory.class);

        Map<String, String> params = new HashMap<String, String>();
        params.put("accept", "ok");
        params.put("reject", "bad");
        ResultConfig config = new ResultConfig.Builder("struts", MyResult.class.getName()).addParams(params).build();
        Map<String, Object> context = new HashMap<String, Object>();

        // when
        Result result = builder.buildResult(config, context);
View Full Code Here

TOP

Related Classes of com.opensymphony.xwork2.config.entities.ResultConfig

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.