Commits

mrdon  committed f3139f5

Added back support for doMethod action methods
XW-394

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

  • Participants
  • Parent commits 31f1e1f

Comments (0)

Files changed (4)

File 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) {

File 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);

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

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

File 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">