Author: hermanns Date: Fri Jun 13 01:33:23 2008 New Revision: 667420 URL: http://svn.apache.org/viewvc?rev=667420&view=rev Log: WW-2660 Patches for WW-2203 prevented action parameters from other places than the request parameters from being included in ParameterAware map. o applied patches by Dale Newfield to S2 and XW o updated xwork dep to 2.1.2-SNAPSHOT
Modified: struts/struts2/trunk/assembly/pom.xml struts/struts2/trunk/core/pom.xml struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ActionMappingParametersInteceptor.java Modified: struts/struts2/trunk/assembly/pom.xml URL: http://svn.apache.org/viewvc/struts/struts2/trunk/assembly/pom.xml?rev=667420&r1=667419&r2=667420&view=diff ============================================================================== --- struts/struts2/trunk/assembly/pom.xml (original) +++ struts/struts2/trunk/assembly/pom.xml Fri Jun 13 01:33:23 2008 @@ -109,7 +109,7 @@ <groupId>com.opensymphony</groupId> <artifactId>xwork</artifactId> <classifier>javadoc</classifier> - <version>2.1.1</version> + <version>2.1.2-SNAPSHOT</version> </artifactItem> </artifactItems> <outputDirectory>${project.build.directory}/xwork-apidocs</outputDirectory> @@ -286,7 +286,7 @@ <dependency> <groupId>com.opensymphony</groupId> <artifactId>xwork</artifactId> - <version>2.1.1</version> + <version>2.1.2-SNAPSHOT</version> <type>jar</type> <classifier>jdk14</classifier> <scope>runtime</scope> Modified: struts/struts2/trunk/core/pom.xml URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/pom.xml?rev=667420&r1=667419&r2=667420&view=diff ============================================================================== --- struts/struts2/trunk/core/pom.xml (original) +++ struts/struts2/trunk/core/pom.xml Fri Jun 13 01:33:23 2008 @@ -56,7 +56,7 @@ <artifactItem> <groupId>com.opensymphony</groupId> <artifactId>xwork</artifactId> - <version>2.1.1</version> + <version>2.1.2-SNAPSHOT</version> <classifier>sources</classifier> </artifactItem> </artifactItems> @@ -229,7 +229,7 @@ <dependency> <groupId>com.opensymphony</groupId> <artifactId>xwork</artifactId> - <version>2.1.1</version> + <version>2.1.2-SNAPSHOT</version> </dependency> <!--<dependency>--> Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ActionMappingParametersInteceptor.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ActionMappingParametersInteceptor.java?rev=667420&r1=667419&r2=667420&view=diff ============================================================================== --- struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ActionMappingParametersInteceptor.java (original) +++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/ActionMappingParametersInteceptor.java Fri Jun 13 01:33:23 2008 @@ -26,6 +26,7 @@ import java.util.Map; import java.util.Collections; +import java.util.TreeMap; import org.apache.struts2.ServletActionContext; import org.apache.struts2.dispatcher.mapper.ActionMapping; @@ -36,31 +37,31 @@ * exactly like [EMAIL PROTECTED] ParametersInterceptor}, only the parameters come from the [EMAIL PROTECTED] ActionMapping}, not the * [EMAIL PROTECTED] ActionContext#getParameters()} method. * <!-- END SNIPPET: description --> - * + * <p/> * <p/> <u>Interceptor parameters:</u> - * + * <p/> * <!-- START SNIPPET: parameters --> - * + * <p/> * <ul> - * + * <p/> * <li>ordered - set to true if you want the top-down property setter behaviour</li> - * + * <p/> * </ul> - * + * <p/> * <!-- END SNIPPET: parameters --> - * + * <p/> * <p/> <u>Extending the interceptor:</u> - * + * <p/> * <!-- START SNIPPET: extending --> - * + * <p/> * <p/> The best way to add behavior to this interceptor is to utilize the [EMAIL PROTECTED] com.opensymphony.xwork2.interceptor.ParameterNameAware} interface in your * actions. However, if you wish to apply a global rule that isn't implemented in your action, then you could extend * this interceptor and override the [EMAIL PROTECTED] #acceptableName(String)} method. - * + * <p/> * <!-- END SNIPPET: extending --> - * + * <p/> * <p/> <u>Example code:</u> - * + * <p/> * <pre> * <!-- START SNIPPET: example --> * <action name="someAction" class="com.examples.SomeAction"> @@ -75,9 +76,9 @@ /** * @param ac The action context * @return the parameters from the action mapping in the context. If none found, returns - * an empty map. + * an empty map. */ - protected Map retrieveParametersFromContext(ActionContext ac) { + protected Map retrieveParameters(ActionContext ac) { ActionMapping mapping = (ActionMapping) ac.get(ServletActionContext.ACTION_MAPPING); if (mapping != null) { return mapping.getParams(); @@ -85,4 +86,26 @@ return Collections.EMPTY_MAP; } } + + /** + * Adds the parameters into context's ParameterMap + * + * @param ac The action context + * @param newParams The parameter map to apply + * <p/> + * In this class this is a no-op, since the parameters were fetched from the same location. + * In subclasses both retrieveParameters() and addParametersToContext() should be overridden. + */ + protected void addParametersToContext(ActionContext ac, Map newParams) { + Map previousParams = ac.getParameters(); + Map combinedParams = null; + if (previousParams != null) { + combinedParams = new TreeMap(previousParams); + } else { + combinedParams = new TreeMap(); + } + combinedParams.putAll(newParams); + + ac.setParameters(combinedParams); + } }