From user-return-215210-apmail-struts-user-archive=struts.apache.org@struts.apache.org Mon Sep 16 06:30:55 2013 Return-Path: X-Original-To: apmail-struts-user-archive@www.apache.org Delivered-To: apmail-struts-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id AE7981002F for ; Mon, 16 Sep 2013 06:30:55 +0000 (UTC) Received: (qmail 6798 invoked by uid 500); 16 Sep 2013 06:30:52 -0000 Delivered-To: apmail-struts-user-archive@struts.apache.org Received: (qmail 6395 invoked by uid 500); 16 Sep 2013 06:30:45 -0000 Mailing-List: contact user-help@struts.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Struts Users Mailing List" Reply-To: "Struts Users Mailing List" Delivered-To: mailing list user@struts.apache.org Received: (qmail 6387 invoked by uid 99); 16 Sep 2013 06:30:42 -0000 Received: from minotaur.apache.org (HELO minotaur.apache.org) (140.211.11.9) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 16 Sep 2013 06:30:42 +0000 Received: from localhost (HELO mail-pd0-f176.google.com) (127.0.0.1) (smtp-auth username lukaszlenart, mechanism plain) by minotaur.apache.org (qpsmtpd/0.29) with ESMTP; Mon, 16 Sep 2013 06:30:41 +0000 Received: by mail-pd0-f176.google.com with SMTP id q10so3712292pdj.35 for ; Sun, 15 Sep 2013 23:30:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=bvjUDEHY0ncdizBYYo+0DG1DchJ7uJFUxZdNUqIv3uU=; b=kvwOw66tvvBfmyHDAULoKh0SMadfE4IKeZYke/NVgBuXSCGXRG3gILIIOPhfKi6kQO KqWEpZ5WjEtUDVLmE6WGmIRkFBEDsdv9L4PNlM0jqT1bmlib/o1+XDRQlBAVixHx1Mf6 NJw1KFZvf5EkO5wGHDLIA02nTaG1LwklPqUOOAT4HjVGlrilsS2ePD6yQ95pPsBO/lGF 0bM0qsT3LGdFlP4IM0hRAiyn5RmdJP1adRgQSGIwVlhtpOVOUhySsQj7PbbUQPoMfFS2 BjCAGs4guLouvsgZTmdxVcGovbIoTxq+SZA+J67N1qXYEhUqRORY88vhE0UlpWz8duo9 Kcfg== X-Received: by 10.66.122.40 with SMTP id lp8mr28939007pab.82.1379313041561; Sun, 15 Sep 2013 23:30:41 -0700 (PDT) MIME-Version: 1.0 Received: by 10.68.20.169 with HTTP; Sun, 15 Sep 2013 23:30:21 -0700 (PDT) In-Reply-To: References: From: Lukasz Lenart Date: Mon, 16 Sep 2013 08:30:21 +0200 Message-ID: Subject: Re: Custom ConfigurationProvider is not able to find result To: Struts Users Mailing List Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable It's hard to analyse such code, can you prepare a demo app on GitHub? And how you register your ConfigurationProvider? Regards --=20 =C5=81ukasz + 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 f= or > result "success" but when the name is set to "success" the message is the= n: > "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 =3D 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 =3D "/trial-package"; > String namespace =3D packageName; > PackageConfig parentPackage =3D > configuration.getPackageConfig("struts-default"); > > PackageConfig.Builder cfg =3D new PackageConfig.Builder(packageNa= me) > .addParent(parentPackage) > .namespace(packageName) > .isAbstract(false) > .strictMethodInvocation(false);//TODO: Consider defaultin= g > this to true > addAction("test", "com.kenmcwilliams.demo.Test2", cfg);//Test > Driven Development! TDD: externalize all this hard wired cfg to a test ca= se > > System.out.println("CONFIGURATION, adding namespace: " + > cfg.getNamespace()); > PackageConfig packageConfig =3D 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 =3D new > ActionConfig.Builder(packageContext.getNamespace(), actionName, clazz); > ResultTypeConfig resultType =3D > packageContext.getResultType("dispatcher"); > > System.out.println("resultType.getClassName():" + > resultType.getClassName()); > System.out.println("resultType.getName():" + resultType.getName()= ); > ResultConfig.Builder resultBuilder =3D new > ResultConfig.Builder(ActionSupport.SUCCESS, resultType.getClassName()); > String jsp =3D "/WEB-INF/other/test.jsp"; > resultBuilder.location(new LocationImpl(jsp, jsp)); > ResultConfig result =3D resultBuilder.build(); > System.out.println("result.getLocation().getURI():" + > result.getLocation().getURI()); > actionBuilder.addResultConfig(result); > ActionConfig action =3D 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