Package com.opensymphony.xwork2.config.entities

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


    }

    public void testClassPath() throws Exception {
        ServletContext context = EasyMock.createNiceMock(ServletContext.class);

        ResultTypeConfig resultType = new ResultTypeConfig.Builder("freemarker", "org.apache.struts2.dispatcher.ServletDispatcherResult").
            defaultResultParam("location").build();
        PackageConfig packageConfig = new PackageConfig.Builder("package").
            defaultResultType("dispatcher").addResultTypeConfig(resultType).build();

        DefaultResultMapBuilder builder = new DefaultResultMapBuilder(context, new ConventionsServiceImpl("/WEB-INF/component"), "dispatcher,velocity,freemarker");
View Full Code Here


        assertEquals(1, results.get("foo").getParams().size());
        assertEquals("/WEB-INF/component/no-annotation-foo.ftl", results.get("foo").getParams().get("location"));
    }

    private PackageConfig createPackageConfigBuilder(String namespace) {
        ResultTypeConfig resultType = new ResultTypeConfig.Builder("dispatcher", "org.apache.struts2.dispatcher.ServletDispatcherResult").
            addParam("key", "value").addParam("key1", "value1").defaultResultParam("location").build();

        ResultTypeConfig redirect  = new ResultTypeConfig.Builder("redirectAction",
            "org.apache.struts2.dispatcher.ServletActionRedirectResult").defaultResultParam("actionName").build();

        ResultTypeConfig ftlResultType = new ResultTypeConfig.Builder("freemarker",
            "org.apache.struts2.views.freemarker.FreemarkerResult").defaultResultParam("location").build();

        return new PackageConfig.Builder("package").
            namespace(namespace).
            defaultResultType("dispatcher").
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

    @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

            // 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

    }

    public void testClassPath() throws Exception {
        ServletContext context = EasyMock.createNiceMock(ServletContext.class);

        ResultTypeConfig resultType = new ResultTypeConfig.Builder("freemarker", "org.apache.struts2.dispatcher.ServletDispatcherResult").
                defaultResultParam("location").build();
        PackageConfig packageConfig = new PackageConfig.Builder("package").
                defaultResultType("dispatcher").addResultTypeConfig(resultType).build();

        this.conventionsService = new ConventionsServiceImpl("/WEB-INF/component");
View Full Code Here

        assertEquals(1, results.get("foo").getParams().size());
        assertEquals("/WEB-INF/component/no-annotation-foo.ftl", results.get("foo").getParams().get("location"));
    }

    private PackageConfig createPackageConfigBuilder(String namespace) {
        ResultTypeConfig resultType = new ResultTypeConfig.Builder("dispatcher", "org.apache.struts2.dispatcher.ServletDispatcherResult").
                addParam("key", "value").addParam("key1", "value1").defaultResultParam("location").build();

        ResultTypeConfig redirect = new ResultTypeConfig.Builder("redirectAction",
                "org.apache.struts2.dispatcher.ServletActionRedirectResult").defaultResultParam("actionName").build();

        ResultTypeConfig ftlResultType = new ResultTypeConfig.Builder("freemarker",
                "org.apache.struts2.views.freemarker.FreemarkerResult").defaultResultParam("location").build();

        return new PackageConfig.Builder("package").
                namespace(namespace).
                defaultResultType("dispatcher").
View Full Code Here

  @Inject
  protected ActionBuilder actionNameBuilder;

  public Result build(String resultCode, ActionConfig actionConfig, ActionContext context) {
    String path = null;
    ResultTypeConfig resultTypeConfig = null;

    logger.debug("result code:{} for actionConfig:{}", resultCode, actionConfig);
    if (null == resultTypeConfigs) {
      PackageConfig pc = configuration.getPackageConfig(actionConfig.getPackageName());
      this.resultTypeConfigs = pc.getAllResultTypeConfigs();
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.