myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r1533538 - in /myfaces/core/trunk/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:29:57 GMT
Author: lu4242
Date: Fri Oct 18 16:29:57 2013
New Revision: 1533538

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

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

Modified: myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/context/flash/FlashImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/context/flash/FlashImpl.java?rev=1533538&r1=1533537&r2=1533538&view=diff
==============================================================================
--- myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/context/flash/FlashImpl.java
(original)
+++ myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/context/flash/FlashImpl.java
Fri Oct 18 16:29:57 2013
@@ -561,7 +561,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/trunk/shared/src/test/java/org/apache/myfaces/shared/context/flash/FlashImplTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/shared/src/test/java/org/apache/myfaces/shared/context/flash/FlashImplTest.java?rev=1533538&r1=1533537&r2=1533538&view=diff
==============================================================================
--- myfaces/core/trunk/shared/src/test/java/org/apache/myfaces/shared/context/flash/FlashImplTest.java
(original)
+++ myfaces/core/trunk/shared/src/test/java/org/apache/myfaces/shared/context/flash/FlashImplTest.java
Fri Oct 18 16:29:57 2013
@@ -491,7 +491,8 @@ public class FlashImplTest extends Abstr
         _flash.setRedirect(true);
         Assert.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);
@@ -613,6 +614,8 @@ public class FlashImplTest extends Abstr
         _flash.setRedirect(true);
         Assert.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.
@@ -651,6 +654,8 @@ public class FlashImplTest extends Abstr
         _flash.setKeepMessages(true);
         Assert.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