You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ta...@apache.org on 2019/07/17 12:10:17 UTC

[myfaces] branch 2.2.x updated: MYFACES-4297 Client Side state / stateless views should not force session creation

This is an automated email from the ASF dual-hosted git repository.

tandraschko pushed a commit to branch 2.2.x
in repository https://gitbox.apache.org/repos/asf/myfaces.git


The following commit(s) were added to refs/heads/2.2.x by this push:
     new c54de6a  MYFACES-4297 Client Side state / stateless views should not force session creation
c54de6a is described below

commit c54de6a218965cc5ff80416954069306c73eac78
Author: Thomas Andraschko <ta...@apache.org>
AuthorDate: Wed Jul 17 14:10:10 2019 +0200

    MYFACES-4297 Client Side state / stateless views should not force session creation
---
 .../view/facelets/FaceletViewDeclarationLanguage.java   | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguage.java b/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguage.java
index 8b5d92e..b82f26f 100644
--- a/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguage.java
+++ b/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguage.java
@@ -2376,7 +2376,8 @@ public class FaceletViewDeclarationLanguage extends FaceletViewDeclarationLangua
 
         // see if we need to override the encoding
         Map<Object, Object> m = context.getAttributes();
-        Map<String, Object> sm = context.getExternalContext().getSessionMap();
+
+        Object session = context.getExternalContext().getSession(false);
 
         // 1. check the request attribute
         if (m.containsKey(PARAM_ENCODING))
@@ -2387,7 +2388,10 @@ public class FaceletViewDeclarationLanguage extends FaceletViewDeclarationLangua
                 log.finest("Facelet specified alternate encoding '" + encoding + "'");
             }
 
-            sm.put(CHARACTER_ENCODING_KEY, encoding);
+            if (session != null)
+            {
+                context.getExternalContext().getSessionMap().put(CHARACTER_ENCODING_KEY, encoding);
+            }
         }
 
         // 2. get it from request
@@ -2399,10 +2403,13 @@ public class FaceletViewDeclarationLanguage extends FaceletViewDeclarationLangua
         // 3. get it from the session
         if (encoding == null)
         {
-            encoding = (String) sm.get(CHARACTER_ENCODING_KEY);
-            if (encoding != null && log.isLoggable(Level.FINEST))
+            if (session != null)
             {
-                log.finest("Session specified alternate encoding '" + encoding + "'");
+                encoding = (String) context.getExternalContext().getSessionMap().get(CHARACTER_ENCODING_KEY);
+                if (encoding != null && log.isLoggable(Level.FINEST))
+                {
+                    log.finest("Session specified alternate encoding '" + encoding + '\'');
+                }
             }
         }