[seam-commits] Seam SVN: r13518 - modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/context.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Tue Jul 27 13:08:56 EDT 2010


Author: lincolnthree
Date: 2010-07-27 13:08:55 -0400 (Tue, 27 Jul 2010)
New Revision: 13518

Modified:
   modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/context/FlashScopedContext.java
Log:
Applied patch for SEAMFACES-42 (NullPointer wrapping External Context)

Modified: modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/context/FlashScopedContext.java
===================================================================
--- modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/context/FlashScopedContext.java	2010-07-27 15:26:49 UTC (rev 13517)
+++ modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/context/FlashScopedContext.java	2010-07-27 17:08:55 UTC (rev 13518)
@@ -68,6 +68,10 @@
    @RequestScoped
    public FlashContext getFlashContext()
    {
+      if (currentContext == null)
+      {
+         initializeCurrentContext();
+      }
       return currentContext;
    }
 
@@ -85,27 +89,21 @@
       }
    }
 
-   /*
-    * PhaseListener Methods
-    */
-   public void beforePhase(final PhaseEvent event)
+   private void initializeCurrentContext()
    {
-      if (PhaseId.RESTORE_VIEW.equals(event.getPhaseId()))
+      String currentId = getCurrentId();
+      if (savedContextExists(currentId))
       {
-         String currentId = getCurrentId();
-         if (savedContextExists(currentId))
-         {
-            FlashContext context = (FlashContext) getSessionMap().get(getSessionKey(currentId));
-            currentContext = context;
-         }
-         else
-         {
-            FlashContextImpl context = new FlashContextImpl();
-            context.setId(getNextFlashId());
-            getSessionMap().put(getSessionKey(context.getId()), context);
-            currentContext = context;
-         }
+         FlashContext context = (FlashContext) getSessionMap().get(getSessionKey(currentId));
+         currentContext = context;
       }
+      else
+      {
+         FlashContextImpl context = new FlashContextImpl();
+         context.setId(getNextFlashId());
+         getSessionMap().put(getSessionKey(context.getId()), context);
+         currentContext = context;
+      }
    }
 
    private String getNextFlashId()
@@ -164,6 +162,11 @@
       }
    }
 
+   public void beforePhase(PhaseEvent arg0)
+   {
+      /* intentionally empty */
+   }
+
    public PhaseId getPhaseId()
    {
       return PhaseId.ANY_PHASE;



More information about the seam-commits mailing list