Author: mrdon
Date: Fri Jun 17 14:29:57 2005
New Revision: 191210
URL: http://svn.apache.org/viewcvs?rev=191210&view=rev
Log:
Adding the ability to insert wildcard-matched values in the properties
of an ActionConfig. This allows you to pass multiple request-time
values to the Action without complicating the "parameter" attibute.
Modified:
struts/core/trunk/doc/userGuide/building_controller.xml
struts/core/trunk/src/share/org/apache/struts/config/ActionConfigMatcher.java
struts/core/trunk/src/test/org/apache/struts/config/TestActionConfigMatcher.java
Modified: struts/core/trunk/doc/userGuide/building_controller.xml
URL:
http://svn.apache.org/viewcvs/struts/core/trunk/doc/userGuide/building_controller.xml?rev=191210&r1=191209&r2=191210&view=diff
==============================================================================
--- struts/core/trunk/doc/userGuide/building_controller.xml (original)
+++ struts/core/trunk/doc/userGuide/building_controller.xml Fri Jun 17 14:29:57
2005
@@ -1465,6 +1465,12 @@
</ul>
<p>
+ Also, the action mapping properties (set using the <code><set-property
key="foo"
+ value="bar"></code> syntax) will accept wildcard-matched strings in
their
+ <code>value</code> attribute.
+ </p>
+
+ <p>
The action forward attributes that will accept wildcard-matched strings
are:
</p>
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?rev=191210&r1=191209&r2=191210&view=diff
==============================================================================
---
struts/core/trunk/src/share/org/apache/struts/config/ActionConfigMatcher.java
(original)
+++
struts/core/trunk/src/share/org/apache/struts/config/ActionConfigMatcher.java
Fri Jun 17 14:29:57 2005
@@ -24,6 +24,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -170,6 +171,15 @@
config.removeForwardConfig(fConfigs[x]);
config.addForwardConfig(cfg);
}
+
+ Properties origProps = orig.getProperties();
+ Properties configProps = config.getProperties();
+ Map.Entry entry = null;
+ for (Iterator i = origProps.entrySet().iterator(); i.hasNext(); ) {
+ entry = (Map.Entry) i.next();
+ configProps.setProperty((String)entry.getKey(),
+ convertParam((String)entry.getValue(), vars));
+ }
ExceptionConfig[] exConfigs = orig.findExceptionConfigs();
for (int x = 0; x < exConfigs.length; x++) {
Modified:
struts/core/trunk/src/test/org/apache/struts/config/TestActionConfigMatcher.java
URL:
http://svn.apache.org/viewcvs/struts/core/trunk/src/test/org/apache/struts/config/TestActionConfigMatcher.java?rev=191210&r1=191209&r2=191210&view=diff
==============================================================================
---
struts/core/trunk/src/test/org/apache/struts/config/TestActionConfigMatcher.java
(original)
+++
struts/core/trunk/src/test/org/apache/struts/config/TestActionConfigMatcher.java
Fri Jun 17 14:29:57 2005
@@ -113,6 +113,7 @@
assertNotNull("ActionConfig should be matched", matched);
assertTrue("ActionConfig should have two action forward",
matched.findForwardConfigs().length == 2);
assertTrue("ActionConfig should have two exception forward",
matched.findExceptionConfigs().length == 2);
+ assertTrue("ActionConfig should have properties",
matched.getProperties().size() == 2);
}
public void testCheckSubstitutionsMatch() {
@@ -138,6 +139,9 @@
assertTrue("Include hasn't been replaced",
"include,Bar".equals(m.getInclude()));
assertTrue("Input hasn't been replaced",
"input,Bar".equals(m.getInput()));
+ assertTrue("ActionConfig property not replaced",
"testBar".equals(m.getProperty("testprop2")));
+
+
ForwardConfig[] fConfigs = m.findForwardConfigs();
boolean found = false;
for (int x=0; x<fConfigs.length; x++) {
@@ -206,6 +210,8 @@
excfg.setPath("path2");
mapping.addExceptionConfig(excfg);
+ mapping.setProperty("testprop", "testval");
+ mapping.setProperty("testprop2", "test{1}");
mapping.freeze();
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]