Anonymous avatar Anonymous committed f3139f5

Added back support for doMethod action methods
XW-394

git-svn-id: http://svn.opensymphony.com/svn/xwork/trunk@1272 e221344d-f017-0410-9bd5-d282ab1896d7

Comments (0)

Files changed (4)

src/java/com/opensymphony/xwork2/DefaultActionInvocation.java

         String timerKey = "invokeAction: "+proxy.getActionName();
         try {
             UtilTimerStack.push(timerKey);
-            Method method = getAction().getClass().getMethod(methodName, new Class[0]);
+            
+            Method method;
+            try {
+                method = getAction().getClass().getMethod(methodName, new Class[0]);
+            } catch (NoSuchMethodException e) {
+                // hmm -- OK, try doXxx instead
+                try {
+                    String altMethodName = "do" + methodName.substring(0, 1).toUpperCase() + methodName.substring(1);
+                    method = getAction().getClass().getMethod(altMethodName, new Class[0]);
+                } catch (NoSuchMethodException e1) {
+                    // throw the original one
+                    throw e;
+                }
+            }
 
             Object methodResult = null;
             if (action instanceof Proxy) {

src/test/com/opensymphony/xwork2/ActionInvocationTest.java

         assertEquals(SimpleAction.COMMAND_RETURN_CODE, commandActionProxy.execute());
     }
     
+    public void testCommandInvocationDoMethod() throws Exception {
+        ActionProxy baseActionProxy = actionProxyFactory.createActionProxy(
+                "baz", "doMethodTest", null);
+        assertEquals("input", baseActionProxy.execute());
+    }
+    
     public void testResultReturnInvocation() throws Exception {
         ActionProxy baseActionProxy = actionProxyFactory.createActionProxy(
                 "baz", "resultAction", null);

src/test/com/opensymphony/xwork2/SimpleAction.java

 
         return SUCCESS;
     }
+    
+    public String doInput() throws Exception {
+        return INPUT;
+    }
 }

src/test/xwork-sample.xml

             <result name="com.opensymphony.xwork2.SimpleAction.CommandInvoked" type="mock"/>
             <interceptor-ref name="logger"/>
         </action>
+        <action name="doMethodTest" class="com.opensymphony.xwork2.SimpleAction" method="input">
+            <result name="input" type="mock" />
+        </action>
         <action name="resultAction" class="com.opensymphony.xwork2.SimpleAction" method="resultAction">
             <param name="bar">456</param>
             <result name="success" type="chain">
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.