Package com.opensymphony.xwork2.config.entities

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


        String defaultResult = packageContext.getFullDefaultResultType();

        for (Map.Entry<String, ResultConfig> entry : results.entrySet()) {

            if (entry.getValue() == null) {
                ResultTypeConfig resultTypeConfig = packageContext.getAllResultTypeConfigs().get(defaultResult);
                entry.setValue(new ResultConfig.Builder(null, resultTypeConfig.getClassName()).build());
            }
        }
    }
View Full Code Here


    assertEquals(resultTypesConfigMap.size(), 2);
    assertTrue(resultTypesConfigMap.containsKey("result1"));
    assertTrue(resultTypesConfigMap.containsKey("result2"));
    assertFalse(resultTypesConfigMap.containsKey("result3"));
   
    ResultTypeConfig result1ResultTypeConfig = (ResultTypeConfig) resultTypesConfigMap.get("result1");
    Map result1ParamsMap = result1ResultTypeConfig.getParams();
    ResultTypeConfig result2ResultTypeConfig = (ResultTypeConfig) resultTypesConfigMap.get("result2");
    Map result2ParamsMap = result2ResultTypeConfig.getParams();
   
    assertEquals(result1ResultTypeConfig.getName(), "result1");
    assertEquals(result1ResultTypeConfig.getClazz(), MockResult.class.getName());
    assertEquals(result2ResultTypeConfig.getName(), "result2");
    assertEquals(result2ResultTypeConfig.getClazz(), MockResult.class.getName());
    assertEquals(result1ParamsMap.size(), 3);
    assertEquals(result2ParamsMap.size(), 2);
    assertTrue(result1ParamsMap.containsKey("param1"));
    assertTrue(result1ParamsMap.containsKey("param2"));
    assertTrue(result1ParamsMap.containsKey("param3"));
View Full Code Here

            // If the URL is /foo and there is an action we can redirect to, send the redirect to /foo/.
            // However, if that action is not in the same namespace, it is the default, so I'm not going
            // to return that.
            if (!actionName.equals("") && redirectToSlash) {
                ResultTypeConfig redirectResultTypeConfig = parentPackage.getAllResultTypeConfigs().get("redirect");
                String redirectNamespace = namespace + "/" + actionName;
                if (LOG.isTraceEnabled()) {
                    LOG.trace("Checking if there is an action named index in the namespace [#0]",
                            redirectNamespace);
                }
View Full Code Here

            if (chainedToConfig != null) {
                if (LOG.isTraceEnabled()) {
                    LOG.trace("Action [#0] used as chain result for [#1] and result [#2]", chainedTo, actionName, resultCode);
                }

                ResultTypeConfig chainResultType = pkg.getAllResultTypeConfigs().get("chain");
                result = buildResult(chainedTo, resultCode, chainResultType, actionContext);
            }
        }

        return result;
View Full Code Here

    @SuppressWarnings(value = {"unchecked"})
    protected ResultConfig createResultConfig(Class<?> actionClass, ResultInfo info,
            PackageConfig packageConfig, Result result) {
        // Look up by the type that was determined from the annotation or by the extension in the
        // ResultInfo class
        ResultTypeConfig resultTypeConfig = packageConfig.getAllResultTypeConfigs().get(info.type);
        if (resultTypeConfig == null) {
            throw new ConfigurationException("The Result type [" + info.type + "] which is" +
                " defined in the Result annotation on the class [" + actionClass + "] or determined" +
                " by the file extension or is the default result type for the PackageConfig of the" +
                " action, could not be found as a result-type defined for the Struts/XWork package [" +
                packageConfig.getName() + "]");
        }

        // Add the default parameters for the result type config (if any)
        HashMap<String, String> params = new HashMap<String, String>();
        if (resultTypeConfig.getParams() != null) {
            params.putAll(resultTypeConfig.getParams());
        }

        // Handle the annotation
        if (result != null) {
            params.putAll(StringTools.createParameterMap(result.params()));
        }

        // Map the location to the default param for the result or a param named location
        if (info.location != null) {
            String defaultParamName = resultTypeConfig.getDefaultResultParam();
            if (!params.containsKey(defaultParamName)) {
                params.put(defaultParamName, info.location);
            }
        }

        return new ResultConfig.Builder(info.name, resultTypeConfig.getClassName()).addParams(params).build();
    }
View Full Code Here

        String determineType(String location, PackageConfig packageConfig,
                Map<String, ResultTypeConfig> resultsByExtension) {
            int indexOfDot = location.lastIndexOf(".");
            if (indexOfDot > 0) {
                String extension = location.substring(indexOfDot + 1);
                ResultTypeConfig resultTypeConfig = resultsByExtension.get(extension);
                if (resultTypeConfig != null) {
                    return resultTypeConfig.getName();
                } else
                    throw new ConfigurationException("Unable to find a result type for extension [" + extension + "] " +
                        "in location attribute [" + location + "].");
            } else {
                return packageConfig.getFullDefaultResultType();
View Full Code Here

        handler.setServletContext((ServletContext)mockServletContext.proxy());
    }

    public void testBuildResult() {
        ActionContext ctx = new ActionContext(new HashMap());
        ResultTypeConfig config = new ResultTypeConfig.Builder("null", SomeResult.class.getName()).defaultResultParam("location").build();
       
        Result result = handler.buildResult("/foo.jsp", "success", config, ctx);
        assertNotNull(result);
        assertTrue(result instanceof SomeResult);
        assertEquals("/foo.jsp", ((SomeResult) result).location);
View Full Code Here

                pkgConfig.namespace(firstParent.getNamespace());
            }
        }


        ResultTypeConfig defaultResultType = packageLoader.getDefaultResultType(pkgConfig);
        ActionConfig actionConfig = new ActionConfig.Builder(actionPackage, actionName, cls.getName())
                .addResultConfigs(new ResultMap<String,ResultConfig>(cls, actionName, defaultResultType))
                .build();
        pkgConfig.addActionConfig(actionName, actionConfig);
    }
View Full Code Here

            // If the URL is /foo and there is an action we can redirect to, send the redirect to /foo/.
            // However, if that action is not in the same namespace, it is the default, so I'm not going
            // to return that.
            if (!actionName.equals("") && redirectToSlash) {
                ResultTypeConfig redirectResultTypeConfig = parentPackage.getAllResultTypeConfigs().get("redirect");
                String redirectNamespace = namespace + "/" + actionName;
                if (LOG.isTraceEnabled()) {
                    LOG.trace("Checking if there is an action named index in the namespace [#0]",
                            redirectNamespace);
                }
View Full Code Here

            if (chainedToConfig != null) {
                if (LOG.isTraceEnabled()) {
                    LOG.trace("Action [#0] used as chain result for [#1] and result [#2]", chainedTo, actionName, resultCode);
                }

                ResultTypeConfig chainResultType = pkg.getAllResultTypeConfigs().get("chain");
                result = buildResult(chainedTo, resultCode, chainResultType, actionContext);
            }
        }

        return result;
View Full Code Here

TOP

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

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.