It's hard to analyse such code, can you prepare a demo app on GitHub? And how you register your ConfigurationProvider? Regards -- Ɓukasz + 48 606 323 122 http://www.lenart.org.pl/ 2013/9/2 Ken McWilliams : > 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 > provider... > > 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; > > @Override > public void destroy() { > } > > @Override > public void init(Configuration configuration) throws > ConfigurationException { > this.configuration = configuration; > } > > @Override > public boolean needsReload() { > return false;//clearly this is conditional on the status of the > model > } > > @Override > public void register(ContainerBuilder cb, LocatableProperties lp) > throws ConfigurationException { > //throw new UnsupportedOperationException("Not supported yet."); > //To change body of generated methods, choose Tools | Templates. > } > > @Override > public void loadPackages() throws ConfigurationException { > String packageName = "/trial-package"; > String namespace = packageName; > PackageConfig parentPackage = > configuration.getPackageConfig("struts-default"); > > PackageConfig.Builder cfg = new PackageConfig.Builder(packageName) > .addParent(parentPackage) > .namespace(packageName) > .isAbstract(false) > .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: " + > cfg.getNamespace()); > PackageConfig packageConfig = cfg.build(); > System.out.println("packageConfig: " + packageConfig); > > configuration.addPackageConfig(cfg.getNamespace(), packageConfig); > //configuration. > } > > private void addAction(String actionName, String clazz, > PackageConfig.Builder packageContext){ > ActionConfig.Builder actionBuilder = new > ActionConfig.Builder(packageContext.getNamespace(), actionName, clazz); > ResultTypeConfig resultType = > packageContext.getResultType("dispatcher"); > > System.out.println("resultType.getClassName():" + > 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 = resultBuilder.build(); > System.out.println("result.getLocation().getURI():" + > result.getLocation().getURI()); > actionBuilder.addResultConfig(result); > ActionConfig action = actionBuilder.build(); > packageContext.addActionConfig(actionName, action); > } > } > > > ** > > > * > * --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@struts.apache.org For additional commands, e-mail: user-help@struts.apache.org