Author: germuska Date: Tue Mar 8 20:25:44 2005 New Revision: 156611 URL: http://svn.apache.org/viewcvs?view=rev&rev=156611 Log: Add command/catalog properties to ForwardConfig, and update the DTD accordingly. Update ActionConfigMatcher to copy those properties when a wildcard is matched, including variable interpolation. Create new ExecuteForwardCommand intended to be executed at the beginning of the "process-view" sub-chain and add to the default chain-config.xml file.
Added: struts/core/trunk/src/share/org/apache/struts/chain/commands/ExecuteForwardCommand.java (with props) Modified: struts/core/trunk/conf/share/chain-config.xml struts/core/trunk/conf/share/struts-config_1_3.dtd struts/core/trunk/src/share/org/apache/struts/chain/commands/ExecuteCommand.java struts/core/trunk/src/share/org/apache/struts/config/ActionConfigMatcher.java struts/core/trunk/src/share/org/apache/struts/config/ForwardConfig.java Modified: struts/core/trunk/conf/share/chain-config.xml URL: http://svn.apache.org/viewcvs/struts/core/trunk/conf/share/chain-config.xml?view=diff&r1=156610&r2=156611 ============================================================================== --- struts/core/trunk/conf/share/chain-config.xml (original) +++ struts/core/trunk/conf/share/chain-config.xml Tue Mar 8 20:25:44 2005 @@ -193,6 +193,13 @@ <!-- ========== View Processing chain ======================== --> <chain name="process-view"> + + + <!-- Lookup and execute a chain command if the current ForwardConfig is + so-configured. --> + <command + className="org.apache.struts.chain.commands.ExecuteForwardCommand"/> + <!-- If you want to use Tiles, uncomment this command and make sure you have the struts-tiles JAR included in your web application. Modified: struts/core/trunk/conf/share/struts-config_1_3.dtd URL: http://svn.apache.org/viewcvs/struts/core/trunk/conf/share/struts-config_1_3.dtd?view=diff&r1=156610&r2=156611 ============================================================================== --- struts/core/trunk/conf/share/struts-config_1_3.dtd (original) +++ struts/core/trunk/conf/share/struts-config_1_3.dtd Tue Mar 8 20:25:44 2005 @@ -280,7 +280,9 @@ --> <!ELEMENT forward (icon?, display-name?, description?, set-property*)> <!ATTLIST forward id ID #IMPLIED> +<!ATTLIST forward catalog CDATA #IMPLIED> <!ATTLIST forward className %ClassName; #IMPLIED> +<!ATTLIST forward command CDATA #IMPLIED> <!ATTLIST forward contextRelative %Boolean; #IMPLIED> <!ATTLIST forward module %RequestPath; #IMPLIED> <!ATTLIST forward name CDATA #REQUIRED> Modified: struts/core/trunk/src/share/org/apache/struts/chain/commands/ExecuteCommand.java URL: http://svn.apache.org/viewcvs/struts/core/trunk/src/share/org/apache/struts/chain/commands/ExecuteCommand.java?view=diff&r1=156610&r2=156611 ============================================================================== --- struts/core/trunk/src/share/org/apache/struts/chain/commands/ExecuteCommand.java (original) +++ struts/core/trunk/src/share/org/apache/struts/chain/commands/ExecuteCommand.java Tue Mar 8 20:25:44 2005 @@ -104,6 +104,16 @@ String catalogName = actionConfig.getCatalog(); + return getCommand(commandName, catalogName); + + } + + /** + * @param commandName + * @param catalogName + * @return + */ + protected Command getCommand(String commandName, String catalogName) { Command command = null; Catalog catalog = null; @@ -125,7 +135,6 @@ log.debug("looking up command " + commandName + " in " + catalogName); return catalog.getCommand(commandName); - } Added: struts/core/trunk/src/share/org/apache/struts/chain/commands/ExecuteForwardCommand.java URL: http://svn.apache.org/viewcvs/struts/core/trunk/src/share/org/apache/struts/chain/commands/ExecuteForwardCommand.java?view=auto&rev=156611 ============================================================================== --- struts/core/trunk/src/share/org/apache/struts/chain/commands/ExecuteForwardCommand.java (added) +++ struts/core/trunk/src/share/org/apache/struts/chain/commands/ExecuteForwardCommand.java Tue Mar 8 20:25:44 2005 @@ -0,0 +1,53 @@ +/* + * $Id$ + * + * Copyright 2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.struts.chain.commands; + +import org.apache.commons.chain.Command; +import org.apache.struts.chain.contexts.ActionContext; +import org.apache.struts.config.ForwardConfig; + +/** + * <p>Look up and execute a commons-chain <code>Command</code> based on properties of + * the ActionContext's <code>forwardConfig</code> property. + * </p> + */ +public class ExecuteForwardCommand extends ExecuteCommand { + + /** + * <p>Return the command specified by the <code>command</code> and + * <code>catalog</code> properties of the <code>forwardConfig</code> + * property of the given <code>ActionContext</code>. If <code>forwardConfig</code> + * is null, return null.</p> + */ + protected Command getCommand(ActionContext context) { + ForwardConfig forwardConfig = context.getForwardConfig(); + if (forwardConfig == null) return null; + return getCommand(forwardConfig.getCommand(), forwardConfig.getCatalog()); + } + + /** + * @return <p><code>true</code> if the given <code>ActionContext</code> has + * a non-null <code>forwardConfig</code> property.</p> + */ + protected boolean shouldProcess(ActionContext context) { + return (context.getForwardConfig() != null); + } +} + + Propchange: struts/core/trunk/src/share/org/apache/struts/chain/commands/ExecuteForwardCommand.java ------------------------------------------------------------------------------ svn:keywords = date author id rev Modified: struts/core/trunk/src/share/org/apache/struts/config/ActionConfigMatcher.java URL: http://svn.apache.org/viewcvs/struts/core/trunk/src/share/org/apache/struts/config/ActionConfigMatcher.java?view=diff&r1=156610&r2=156611 ============================================================================== --- struts/core/trunk/src/share/org/apache/struts/config/ActionConfigMatcher.java (original) +++ struts/core/trunk/src/share/org/apache/struts/config/ActionConfigMatcher.java Tue Mar 8 20:25:44 2005 @@ -165,6 +165,8 @@ cfg.setName(fConfigs[x].getName()); cfg.setPath(convertParam(fConfigs[x].getPath(), vars)); cfg.setRedirect(fConfigs[x].getRedirect()); + cfg.setCommand(convertParam(fConfigs[x].getCommand(), vars)); + cfg.setCatalog(convertParam(fConfigs[x].getCatalog(), vars)); config.removeForwardConfig(fConfigs[x]); config.addForwardConfig(cfg); } Modified: struts/core/trunk/src/share/org/apache/struts/config/ForwardConfig.java URL: http://svn.apache.org/viewcvs/struts/core/trunk/src/share/org/apache/struts/config/ForwardConfig.java?view=diff&r1=156610&r2=156611 ============================================================================== --- struts/core/trunk/src/share/org/apache/struts/config/ForwardConfig.java (original) +++ struts/core/trunk/src/share/org/apache/struts/config/ForwardConfig.java Tue Mar 8 20:25:44 2005 @@ -234,6 +234,43 @@ this.redirect = redirect; } + /** + * <p>The name of a <code>commons-chain</code> command which should be + * looked up and executed before Struts dispatches control to the view + * represented by this config.</p> + */ + protected String command = null; + + public String getCommand() { + return (this.command); + } + + public void setCommand(String command) { + if (configured) { + throw new IllegalStateException("Configuration is frozen"); + } + this.command = command; + } + + /** + * <p>The name of a <code>commons-chain</code> catalog in which <code>command</code> + * should be looked up. If this value is undefined, then the command will be + * looked up in the "default" catalog. This value has no meaning except in + * the context of the <code>command</code> property.</p> + */ + protected String catalog = null; + + public String getCatalog() { + return (this.catalog); + } + + public void setCatalog(String catalog) { + if (configured) { + throw new IllegalStateException("Configuration is frozen"); + } + this.catalog = catalog; + } + // --------------------------------------------------------- Public Methods --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]