You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by de...@apache.org on 2015/11/27 16:31:34 UTC

svn commit: r1716888 - in /myfaces/core/trunk: api/src/main/java/javax/faces/component/UIViewRoot.java shared/src/main/java/org/apache/myfaces/shared/context/flash/FlashImpl.java

Author: deki
Date: Fri Nov 27 15:31:33 2015
New Revision: 1716888

URL: http://svn.apache.org/viewvc?rev=1716888&view=rev
Log:
MYFACES-3987: improved robustness

Modified:
    myfaces/core/trunk/api/src/main/java/javax/faces/component/UIViewRoot.java
    myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/context/flash/FlashImpl.java

Modified: myfaces/core/trunk/api/src/main/java/javax/faces/component/UIViewRoot.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/component/UIViewRoot.java?rev=1716888&r1=1716887&r2=1716888&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/component/UIViewRoot.java (original)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/component/UIViewRoot.java Fri Nov 27 15:31:33 2015
@@ -829,17 +829,19 @@ public class UIViewRoot extends UICompon
     {
         if (_viewScope == null && create)
         {
-            FacesContext facesContext = getFacesContext();
             if (VIEW_SCOPE_PROXY_MAP_CLASS != null)
             {
-                _viewScope = (Map<String, Object>) 
+                _viewScope = (Map<String, Object>)
                     _ClassUtils.newInstance(VIEW_SCOPE_PROXY_MAP_CLASS);
-                facesContext.getApplication().publishEvent(facesContext, PostConstructViewMapEvent.class, this);
             }
             else
             {
                 //Default to map for testing purposes
                 _viewScope = new ViewScope();
+            }
+            FacesContext facesContext = getFacesContext();
+            if (facesContext != null)
+            {
                 facesContext.getApplication().publishEvent(facesContext, PostConstructViewMapEvent.class, this);
             }
         }

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=1716888&r1=1716887&r2=1716888&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 Nov 27 15:31:33 2015
@@ -392,9 +392,13 @@ public class FlashImpl extends Flash imp
     public boolean isKeepMessages()
     {
         FacesContext facesContext = FacesContext.getCurrentInstance();
-        ExternalContext externalContext = facesContext.getExternalContext();
-        Map<String, Object> requestMap = externalContext.getRequestMap();
-        Boolean keepMessages = (Boolean) requestMap.get(FLASH_KEEP_MESSAGES);
+        Boolean keepMessages = null;
+        if (facesContext != null)
+        {
+            ExternalContext externalContext = facesContext.getExternalContext();
+            Map<String, Object> requestMap = externalContext.getRequestMap();
+            keepMessages = (Boolean) requestMap.get(FLASH_KEEP_MESSAGES);
+        }
         
         return (keepMessages == null ? Boolean.FALSE : keepMessages);
     }
@@ -747,7 +751,7 @@ public class FlashImpl extends Flash imp
      * Take the render map key and store it as a key for the next request.
      * 
      * On the next request we can get it with _getRenderFlashMapTokenFromPreviousRequest().
-     * @param externalContext
+     * @param facesContext
      */
     private void _saveRenderFlashMapTokenForNextRequest(FacesContext facesContext)
     {
@@ -790,7 +794,7 @@ public class FlashImpl extends Flash imp
      * 
      * Returns the value of _saveRenderFlashMapTokenForNextRequest() from
      * the previous request.
-     * @param externalContext
+     * @param facesContext
      * @return
      */
     private String _getRenderFlashMapTokenFromPreviousRequest(FacesContext facesContext)