dev@javaserverfaces.java.net

Re: Seeking Review: [1449-FlashAndClustering]

From: Ken Paulsen <Ken.Paulsen_at_Sun.COM>
Date: Wed, 09 Dec 2009 15:18:00 -0800

Hi Ed,

Thanks for the rationale for app scope, makes sense.

Review comment:

    The class documentation for ELFlash.java needs to be updated (currently says it never touches Session, etc.).

Thanks!

Ken

Ed Burns wrote:
On Wed, 09 Dec 2009 10:00:38 -0800, Ken Paulsen <Ken.Paulsen@Sun.COM> said:
            

KP> Ed, what is the advantage of storing it in Application scope in some cases?

Because the flash, combined with view parameters and h:link/h:button,
enables an entirely PRG friendly, sessionless application without much
of a sacrifice in functionality.

However, in the tech meeting today we decided it wasn't worth it to
enable this case, so I'm just going to move it to the session.

https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1449

Can someone please review this?  Ryan?

Issue: 1449

Make the Flash cluster friendly.


SECTION: Modified Files
----------------------------
M       jsf-ri/src/com/sun/faces/context/flash/ELFlash.java


SECTION: Diffs
----------------------------
Index: jsf-ri/src/com/sun/faces/context/flash/ELFlash.java
===================================================================
--- jsf-ri/src/com/sun/faces/context/flash/ELFlash.java	(revision 8229)
+++ jsf-ri/src/com/sun/faces/context/flash/ELFlash.java	(working copy)
@@ -266,15 +266,15 @@
      */
     
     public static ELFlash getFlash(ExternalContext extContext, boolean create) {
-        Map<String, Object> appMap = extContext.getApplicationMap();
+        Map<String, Object> sessionMap = extContext.getSessionMap();
         ELFlash flash = (ELFlash) 
-            appMap.get(FLASH_ATTRIBUTE_NAME);
+            sessionMap.get(FLASH_ATTRIBUTE_NAME);
         if (null == flash && create) {
             synchronized (extContext.getContext()) {
                 if (null == (flash = (ELFlash)
-                    appMap.get(FLASH_ATTRIBUTE_NAME))) {
+                    sessionMap.get(FLASH_ATTRIBUTE_NAME))) {
                     flash = new ELFlash();
-                    appMap.put(FLASH_ATTRIBUTE_NAME, flash);
+                    sessionMap.put(FLASH_ATTRIBUTE_NAME, flash);
                 }
             }
         }
@@ -711,6 +711,9 @@
 
     private Map<String, Object> getPhaseMapForWriting() {
         FacesContext context = FacesContext.getCurrentInstance();
+        Map<String, Object> sessionMap = context.getExternalContext().getSessionMap();
+        sessionMap.put(FLASH_ATTRIBUTE_NAME, this);
+
         Map<String, Object> result = null;
         PhaseId currentPhase = context.getCurrentPhaseId();
         Map<Object, Object> contextMap = context.getAttributes();

Thanks,

Ed