myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r1533534 - in /myfaces/core/branches/2.0.x/shared/src: main/java/org/apache/myfaces/shared/context/flash/FlashImpl.java test/java/org/apache/myfaces/shared/context/flash/FlashImplTest.java
Date Fri, 18 Oct 2013 16:19:43 GMT
Author: lu4242
Date: Fri Oct 18 16:19:43 2013
New Revision: 1533534

URL: http://svn.apache.org/r1533534
Log:
MYFACES-3752 Flash.setKeepMessages(true) does not work with immediate-Commandbutton

Modified:
    myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/context/flash/FlashImpl.java
    myfaces/core/branches/2.0.x/shared/src/test/java/org/apache/myfaces/shared/context/flash/FlashImplTest.java

Modified: myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/context/flash/FlashImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/context/flash/FlashImpl.java?rev=1533534&r1=1533533&r2=1533534&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/context/flash/FlashImpl.java
(original)
+++ myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/context/flash/FlashImpl.java
Fri Oct 18 16:19:43 2013
@@ -538,7 +538,10 @@ public class FlashImpl extends Flash
         final PhaseId currentPhaseId = facesContext.getCurrentPhaseId();
         
         boolean lastPhaseNormalRequest = PhaseId.RENDER_RESPONSE.equals(currentPhaseId);
-        boolean lastPhaseIfRedirect = PhaseId.INVOKE_APPLICATION.equals(currentPhaseId) 
+        // According to the spec, if there is a redirect, responseComplete() 
+        // has been called, and Flash.setRedirect() has been called too,
+        // so we just need to check both are present.
+        boolean lastPhaseIfRedirect = facesContext.getResponseComplete()
                 && _isRedirectTrueOnThisRequest(facesContext);
         
         return lastPhaseNormalRequest || lastPhaseIfRedirect;

Modified: myfaces/core/branches/2.0.x/shared/src/test/java/org/apache/myfaces/shared/context/flash/FlashImplTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/shared/src/test/java/org/apache/myfaces/shared/context/flash/FlashImplTest.java?rev=1533534&r1=1533533&r2=1533534&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/shared/src/test/java/org/apache/myfaces/shared/context/flash/FlashImplTest.java
(original)
+++ myfaces/core/branches/2.0.x/shared/src/test/java/org/apache/myfaces/shared/context/flash/FlashImplTest.java
Fri Oct 18 16:19:43 2013
@@ -471,7 +471,8 @@ public class FlashImplTest extends Abstr
         _flash.setRedirect(true);
         assertTrue("setRedirect(true) was just called, thus isRedirect() must be true",
                 _flash.isRedirect());
-        
+        // The redirect cause responseComplete() method to be called.
+        facesContext.responseComplete();
         // note that setRedirect(true) was called, thus the cleanup happens
         // in phase 5, because doPostPhaseActions() won't be called on phase 6.
         _flash.doPostPhaseActions(facesContext);
@@ -592,6 +593,8 @@ public class FlashImplTest extends Abstr
         _flash.setRedirect(true);
         assertTrue("setRedirect(true) was just called, thus isRedirect() must be true",
                 _flash.isRedirect());
+        // The redirect cause responseComplete() method to be called.
+        facesContext.responseComplete();
         
         // note that setRedirect(true) was called, thus the cleanup happens
         // in phase 5, because doPostPhaseActions() won't be called on phase 6.
@@ -630,6 +633,8 @@ public class FlashImplTest extends Abstr
         _flash.setKeepMessages(true);
         assertTrue("setKeepMessages(true) was just called, thus isKeepMessages() "
                 + "must be true.", _flash.isKeepMessages());
+        // The redirect cause responseComplete() method to be called.
+        facesContext.responseComplete();
         
         _flash.doPostPhaseActions(facesContext);
         



Mime
View raw message