Commits

mrdon  committed a90f8f1

Added autowiring of Result objects when returned from an action method
WW-2598

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

  • Participants
  • Parent commits 0aeb6ad

Comments (0)

Files changed (3)

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

 
             if (methodResult instanceof Result) {
                 this.explicitResult = (Result) methodResult;
+
+                // Wire the result automatically
+                container.inject(explicitResult);
                 return null;
             } else {
                 return (String) methodResult;

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

         assertEquals("found", baseActionProxy.execute());
     }
     
-    public void testResultReturnInvocation() throws Exception {
+    public void testResultReturnInvocationAndWired() throws Exception {
         ActionProxy baseActionProxy = actionProxyFactory.createActionProxy(
                 "baz", "resultAction", null, null);
         assertEquals(null, baseActionProxy.execute());

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

  */
 package com.opensymphony.xwork2;
 
+import com.opensymphony.xwork2.config.Configuration;
+import com.opensymphony.xwork2.inject.Inject;
+
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
     
     public Result resultAction() throws Exception {
     	return new Result() {
+            public Configuration configuration;
 
+            @Inject
+            public void setConfiguration(Configuration config) {
+                this.configuration = config;
+            }
             public void execute(ActionInvocation invocation) throws Exception {
-                resultCalled = true;
+                if (configuration != null)
+                    resultCalled = true;
             }
     	    
     	};