struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ken McWilliams <>
Subject Custom ConfigurationProvider is not able to find result
Date Mon, 02 Sep 2013 06:29:30 GMT
Probably something silly but the following is just a rough effort at
proving to myself that I can add a new action though a configuration

It adds the package and action but there is something wrong with the
result. If the results name is set to "error" I get there is no mapping for
result "success" but when the name is set to "success" the message is then:
"message *result 'null' not found"

So it seems the result is mostly configured correctly...

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.config.Configuration;
import com.opensymphony.xwork2.config.ConfigurationException;
import com.opensymphony.xwork2.config.ConfigurationProvider;
import com.opensymphony.xwork2.config.entities.ActionConfig;
import com.opensymphony.xwork2.config.entities.PackageConfig;
import com.opensymphony.xwork2.config.entities.ResultConfig;
import com.opensymphony.xwork2.config.entities.ResultTypeConfig;
import com.opensymphony.xwork2.inject.ContainerBuilder;
import com.opensymphony.xwork2.util.location.LocatableProperties;
import com.opensymphony.xwork2.util.location.LocationImpl;

public class DBConfigurationProvider implements ConfigurationProvider {

    private Configuration configuration;

    public void destroy() {

    public void init(Configuration configuration) throws
ConfigurationException {
        this.configuration = configuration;

    public boolean needsReload() {
        return false;//clearly this is conditional on the status of the

    public void register(ContainerBuilder cb, LocatableProperties lp)
throws ConfigurationException {
        //throw new UnsupportedOperationException("Not supported yet.");
//To change body of generated methods, choose Tools | Templates.

    public void loadPackages() throws ConfigurationException {
        String packageName = "/trial-package";
        String namespace = packageName;
        PackageConfig parentPackage =

        PackageConfig.Builder cfg = new PackageConfig.Builder(packageName)
                .strictMethodInvocation(false);//TODO: Consider defaulting
this to true
        addAction("test", "com.kenmcwilliams.demo.Test2", cfg);//Test
Driven Development! TDD: externalize all this hard wired cfg to a test case

        System.out.println("CONFIGURATION, adding namespace: " +
        PackageConfig packageConfig =;
        System.out.println("packageConfig: " + packageConfig);

        configuration.addPackageConfig(cfg.getNamespace(), packageConfig);

    private void addAction(String actionName, String clazz,
PackageConfig.Builder packageContext){
        ActionConfig.Builder actionBuilder = new
ActionConfig.Builder(packageContext.getNamespace(), actionName, clazz);
        ResultTypeConfig resultType =

        System.out.println("resultType.getClassName():" +
        System.out.println("resultType.getName():" + resultType.getName());
        ResultConfig.Builder resultBuilder = new
ResultConfig.Builder(ActionSupport.SUCCESS, resultType.getClassName());
        String jsp = "/WEB-INF/other/test.jsp";
        resultBuilder.location(new LocationImpl(jsp, jsp));
        ResultConfig result =;
        System.out.println("result.getLocation().getURI():" +
        ActionConfig action =;
        packageContext.addActionConfig(actionName, action);



  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message