Commits

Anonymous committed bdfe647

XW-116: Clarifying why it checks for executed and moving PreResultListener calls...

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

Comments (0)

Files changed (1)

src/java/com/opensymphony/xwork/DefaultActionInvocation.java

     }
 
     /**
-    * If the DefaultActionInvocation has been executed before and the Result is an instance of ActionChainResult, this method
-    * will walk down the chain of ActionChainResults until it finds a non-chain result, which will be returned. If the
-    * DefaultActionInvocation's result has not been executed before, the Result instance will be created and populated with
-    * the result params.
-    * @return a Result instance
-    * @throws Exception
-    */
+* If the DefaultActionInvocation has been executed before and the Result is an instance of ActionChainResult, this method
+* will walk down the chain of ActionChainResults until it finds a non-chain result, which will be returned. If the
+* DefaultActionInvocation's result has not been executed before, the Result instance will be created and populated with
+* the result params.
+* @return a Result instance
+* @throws Exception
+*/
     public Result getResult() throws Exception {
         if (result != null) {
             Result returnResult = result;
     }
 
     /**
-     * Register a com.opensymphony.xwork.interceptor.PreResultListener to be notified after the Action is executed and before the
-     * Result is executed. The ActionInvocation implementation must guarantee that listeners will be called in the order
-     * in which they are registered. Listener registration and execution does not need to be thread-safe.
-     * @param listener
-     */
+ * Register a com.opensymphony.xwork.interceptor.PreResultListener to be notified after the Action is executed and before the
+ * Result is executed. The ActionInvocation implementation must guarantee that listeners will be called in the order
+ * in which they are registered. Listener registration and execution does not need to be thread-safe.
+ * @param listener
+ */
     public void addPreResultListener(PreResultListener listener) {
         if (preResultListeners == null) {
             preResultListeners = new ArrayList(1);
             }
         }
 
-        if (preResultListeners != null) {
-            for (Iterator iterator = preResultListeners.iterator();
-                    iterator.hasNext();) {
-                PreResultListener listener = (PreResultListener) iterator.next();
-                listener.beforeResult(this, resultCode);
+        // this is needed because the result will be executed, then control will return to the Interceptor, which will
+        // return above and flow through again
+        if (!executed) {
+            if (preResultListeners != null) {
+                for (Iterator iterator = preResultListeners.iterator();
+                        iterator.hasNext();) {
+                    PreResultListener listener = (PreResultListener) iterator.next();
+                    listener.beforeResult(this, resultCode);
+                }
             }
-        }
 
-        if (!executed) {
             // now execute the result, if we're supposed to
             if (proxy.getExecuteResult()) {
                 executeResult();
     }
 
     /**
-    * Uses getResult to get the final Result and executes it
-    */
+* Uses getResult to get the final Result and executes it
+*/
     private void executeResult() throws Exception {
         Result aResult = getResult();
 
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.