Commits

Anonymous committed 9d17c3a

Cleaned up a few webwork references, better handling of returned
objects from an action method

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

Comments (0)

Files changed (8)

src/java/com/opensymphony/xwork2/ActionChainResult.java

     private String namespace;
     
     private String methodName;
+    
+    public ActionChainResult() {
+    	super();
+    }
+    
+    public ActionChainResult(String namespace, String actionName, String methodName) {
+    	this.namespace = namespace;
+    	this.actionName = actionName;
+    	this.methodName = methodName;
+    }
 
 
     public void setActionName(String actionName) {

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

 
     public Result createResult() throws Exception {
 
+    	if (result != null) {
+    		return result;
+    	}
         ActionConfig config = proxy.getConfig();
         Map results = config.getResults();
 
             UtilTimerStack.push(timerKey);
             Method method = getAction().getClass().getMethod(methodName, new Class[0]);
 
+            Object methodResult = null;
             if (action instanceof Proxy) {
                 try {
-                    return (String) Proxy.getInvocationHandler(action).invoke(action, method, new Object[0]);
+                    methodResult = Proxy.getInvocationHandler(action).invoke(action, method, new Object[0]);
                 } catch (Throwable throwable) {
                     throwable.printStackTrace();
                     throw new Exception("Error invoking on proxy: " + throwable.getMessage());
                 }
             } else {
-                return (String) method.invoke(action, new Object[0]);
+                methodResult = method.invoke(action, new Object[0]);
+            }
+            if (methodResult instanceof Result) {
+            	this.result = (Result) methodResult;
+            	return null;
+            } else {
+            	return (String) methodResult;
             }
         } catch (NoSuchMethodException e) {
             throw new IllegalArgumentException("The " + methodName + "() is not defined in action " + getAction().getClass() + "");

src/java/com/opensymphony/xwork2/config/ConfigurationManager.java

 
 
     /**
-     * reloads the Configuration files if the configuration files indicate that they need to be reloaded.
-     * <p/>
-     * <B>NOTE:</b> FileManager could be configured through webwork.properties through
-     * webwork.configuration.xml.reload  property.
+     * Reloads the Configuration files if the configuration files indicate that they need to be reloaded.
      */
     public synchronized void conditionalReload() {
         if (FileManager.isReloadingConfigs()) {

src/java/com/opensymphony/xwork2/interceptor/AliasInterceptor.java

  *     &lt;!-- The value for the foo parameter will be applied as if it were named bar --&gt;
  *     &lt;param name="aliases"&gt;#{ 'foo' : 'bar' }&lt;/param&gt;
  *
- *     &lt;!-- note: the alias interceptor is included with the defaultStack in webwork-default.xml --&gt;
  *     &lt;interceptor-ref name="alias"/&gt;
  *     &lt;interceptor-ref name="basicStack"/&gt;
  *     &lt;result name="success"&gt;good_result.ftl&lt;/result&gt;

src/java/com/opensymphony/xwork2/interceptor/ExceptionMappingInterceptor.java

  * <pre>
  * <!-- START SNIPPET: example -->
  * &lt;xwork&gt;
- *     &lt;include file="webwork-default.xml"/&gt;
- *
- *     &lt;package name="default" extends="webwork-default"&gt;
+ *     &lt;package name="default" extends="xwork-default"&gt;
  *         &lt;global-results&gt;
  *             &lt;result name="success" type="freemarker"&gt;error.ftl&lt;/result&gt;
  *         &lt;/global-results&gt;
  * <pre>
  * <!-- START SNIPPET: example2 -->
  * &lt;xwork&gt;
- *   &lt;include file="webwork-default.xml"/&gt;
- *     
- *   &lt;package name="something" extends="webwork-default"&gt;
+ *   &lt;package name="something" extends="xwork-default"&gt;
  *      &lt;interceptors&gt;
  *          &lt;interceptor-stack name="exceptionmapping-stack"&gt;
  *              &lt;interceptor-ref name="exception"&gt;

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

                 "baz", "myCommand", null);
         assertEquals(SimpleAction.COMMAND_RETURN_CODE, commandActionProxy.execute());
     }
+    
+    public void testResultReturnInvocation() throws Exception {
+        ActionProxy baseActionProxy = ActionProxyFactory.getFactory().createActionProxy(configurationManager.getConfiguration(),
+                "baz", "resultAction", null);
+        assertEquals(null, baseActionProxy.execute());
+    }
 
     public void testSimple() {
         HashMap params = new HashMap();

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

     public String commandMethod() throws Exception {
         return COMMAND_RETURN_CODE;
     }
+    
+    public Result resultAction() throws Exception {
+    	return new VoidResult();
+    }
 
     public String exceptionMethod() throws Exception {
         if (throwException) {

src/test/xwork-sample.xml

             <result name="com.opensymphony.xwork2.SimpleAction.CommandInvoked" type="mock"/>
             <interceptor-ref name="logger"/>
         </action>
+        <action name="resultAction" class="com.opensymphony.xwork2.SimpleAction" method="resultAction">
+            <param name="bar">456</param>
+            <result name="success" type="chain">
+                <param name="actionName">foo</param>
+            </result>
+            <interceptor-ref name="logger"/>
+        </action>
     </package>
 
     <package name="multipleInheritance" extends="default,abstractPackage,bar" namespace="multipleInheritance">