You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by mr...@apache.org on 2005/10/28 05:25:05 UTC

svn commit: r329061 - in /struts/core/trunk: src/java/org/apache/struts/config/ActionConfigMatcher.java src/test/org/apache/struts/config/TestActionConfigMatcher.java xdocs/userGuide/building_controller.xml

Author: mrdon
Date: Thu Oct 27 20:25:01 2005
New Revision: 329061

URL: http://svn.apache.org/viewcvs?rev=329061&view=rev
Log:
 * Adding a few more attributes and properties to the wildcard matcher
 * Updating the wildcard documentation

Modified:
    struts/core/trunk/src/java/org/apache/struts/config/ActionConfigMatcher.java
    struts/core/trunk/src/test/org/apache/struts/config/TestActionConfigMatcher.java
    struts/core/trunk/xdocs/userGuide/building_controller.xml

Modified: struts/core/trunk/src/java/org/apache/struts/config/ActionConfigMatcher.java
URL: http://svn.apache.org/viewcvs/struts/core/trunk/src/java/org/apache/struts/config/ActionConfigMatcher.java?rev=329061&r1=329060&r2=329061&view=diff
==============================================================================
--- struts/core/trunk/src/java/org/apache/struts/config/ActionConfigMatcher.java (original)
+++ struts/core/trunk/src/java/org/apache/struts/config/ActionConfigMatcher.java Thu Oct 27 20:25:01 2005
@@ -163,6 +163,9 @@
         config.setInput(convertParam(orig.getInput(), vars));
         config.setCatalog(convertParam(orig.getCatalog(), vars));
         config.setCommand(convertParam(orig.getCommand(), vars));
+        config.setMultipartClass(convertParam(orig.getMultipartClass(), vars));
+        config.setPrefix(convertParam(orig.getPrefix(), vars));
+        config.setSuffix(convertParam(orig.getSuffix(), vars));
 
         ForwardConfig[] fConfigs = orig.findForwardConfigs();
         ForwardConfig cfg;
@@ -173,18 +176,14 @@
             cfg.setRedirect(fConfigs[x].getRedirect());
             cfg.setCommand(convertParam(fConfigs[x].getCommand(), vars));
             cfg.setCatalog(convertParam(fConfigs[x].getCatalog(), vars));
+            
+            replaceProperties(fConfigs[x].getProperties(), cfg.getProperties(), vars);
+            
             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));
-        } 
+        replaceProperties(orig.getProperties(), config.getProperties(), vars);
 
         ExceptionConfig[] exConfigs = orig.findExceptionConfigs();
         for (int x = 0; x < exConfigs.length; x++) {
@@ -194,6 +193,15 @@
         config.freeze();
 
         return config;
+    }
+    
+    protected void replaceProperties(Properties orig, Properties props, Map vars) {
+        Map.Entry entry = null;
+        for (Iterator i = orig.entrySet().iterator(); i.hasNext(); ) {
+            entry = (Map.Entry) i.next();
+            props.setProperty((String)entry.getKey(), 
+                convertParam((String)entry.getValue(), vars));
+        } 
     }
 
     /**

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=329061&r1=329060&r2=329061&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 Thu Oct 27 20:25:01 2005
@@ -125,12 +125,12 @@
         
         assertTrue("Name hasn't been replaced", "name,Bar".equals(m.getName()));
         assertTrue("Path hasn't been replaced", "/fooBar".equals(m.getPath()));
-        assertTrue("Prefix isn't correct", "foo".equals(m.getPrefix()));
         assertTrue("Scope isn't correct", "request".equals(m.getScope()));
-        assertTrue("Suffix isn't correct", "bar".equals(m.getSuffix()));
         assertTrue("Unknown isn't correct", !m.getUnknown());
         assertTrue("Validate isn't correct", m.getValidate());
 
+        assertTrue("Prefix hasn't been replaced", "foo,Bar".equals(m.getPrefix()));
+        assertTrue("Suffix hasn't been replaced", "bar,Bar".equals(m.getSuffix()));
         assertTrue("Type hasn't been replaced", "foo.bar.BarAction".equals(m.getType()));
         assertTrue("Roles hasn't been replaced", "public,Bar".equals(m.getRoles()));
         assertTrue("Parameter hasn't been replaced", "param,Bar".equals(m.getParameter()));
@@ -149,6 +149,7 @@
             if ("name".equals(cfg.getName())) {
                 found = true;
                 assertTrue("Path hasn't been replaced", "path,Bar".equals(cfg.getPath()));
+                assertTrue("Property foo hasn't been replaced", "bar,Bar".equals(cfg.getProperty("foo")));
             }
         }
         assertTrue("The forward config 'name' cannot be found", found);
@@ -171,12 +172,13 @@
 
         mapping.setName("name,{1}");
         mapping.setPath(path);
-        mapping.setPrefix("foo");
         mapping.setScope("request");
-        mapping.setSuffix("bar");
         mapping.setUnknown(false);
         mapping.setValidate(true);
 
+        mapping.setPrefix("foo,{1}");
+        mapping.setSuffix("bar,{1}");
+        
         mapping.setType("foo.bar.{1}Action");
         mapping.setRoles("public,{1}");
         mapping.setParameter("param,{1}");
@@ -188,6 +190,7 @@
         ForwardConfig cfg = new ActionForward();
         cfg.setName("name");
         cfg.setPath("path,{1}");
+        cfg.setProperty("foo", "bar,{1}");
         mapping.addForwardConfig(cfg);
         
         cfg = new ActionForward();

Modified: struts/core/trunk/xdocs/userGuide/building_controller.xml
URL: http://svn.apache.org/viewcvs/struts/core/trunk/xdocs/userGuide/building_controller.xml?rev=329061&r1=329060&r2=329061&view=diff
==============================================================================
--- struts/core/trunk/xdocs/userGuide/building_controller.xml (original)
+++ struts/core/trunk/xdocs/userGuide/building_controller.xml Thu Oct 27 20:25:01 2005
@@ -1573,14 +1573,19 @@
     </p>
 
     <ul>
-        <li><code>type</code></li>
-        <li><code>name</code></li>
-        <li><code>roles</code></li>
-        <li><code>parameter</code></li>
         <li><code>attribute</code></li>
+        <li><code>catalog</code></li>
+        <li><code>command</code></li>
         <li><code>forward</code></li>
         <li><code>include</code></li>
         <li><code>input</code></li>
+        <li><code>multipartClass</code></li>
+        <li><code>name</code></li>
+        <li><code>parameter</code></li>
+        <li><code>prefix</code></li>
+        <li><code>roles</code></li>
+        <li><code>suffix</code></li>
+        <li><code>type</code></li>
     </ul>
 
     <p>
@@ -1593,10 +1598,18 @@
     The action forward attributes that will accept wildcard-matched strings
     are:
     </p>
-
+    
     <ul>
+        <li><code>catalog</code></li>
+        <li><code>command</code></li>
         <li><code>path</code></li>
     </ul>
+    
+    <p>
+    Like the action mapping, the action forward properties (set using the 
+    <code>&lt;set-property key="foo" value="bar"&gt;</code> syntax) will 
+    accept wildcard-matched strings in their <code>value</code> attribute.
+    </p>
 
 </subsection>
 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org