myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mat...@apache.org
Subject svn commit: r711799 - /myfaces/trinidad/branches/1.2.8.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/StateManagerImpl.java
Date Thu, 06 Nov 2008 08:49:56 GMT
Author: matzew
Date: Thu Nov  6 00:49:55 2008
New Revision: 711799

URL: http://svn.apache.org/viewvc?rev=711799&view=rev
Log:
TRINIDAD-1289 - _activePageState in StatemManagerImpl should be on the session level

thx to Blake Sullivan for the patch

Modified:
    myfaces/trinidad/branches/1.2.8.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/StateManagerImpl.java

Modified: myfaces/trinidad/branches/1.2.8.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/StateManagerImpl.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.8.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/StateManagerImpl.java?rev=711799&r1=711798&r2=711799&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.8.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/StateManagerImpl.java
(original)
+++ myfaces/trinidad/branches/1.2.8.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/application/StateManagerImpl.java
Thu Nov  6 00:49:55 2008
@@ -294,16 +294,20 @@
     if (_saveAsToken(context))
     {
       String token;
+      ExternalContext extContext = context.getExternalContext();
+
       if (applicationViewCache == null)
       {
         assert(!dontSave);
         TokenCache cache = _getViewCache(context);
         assert(cache != null);
 
+        Map<String, Object> sessionMap = extContext.getSessionMap();
+
         // Store bits of the session as subkeys off of the session
-        Map<String, PageState> stateMap = new SubKeyMap<PageState>(
-                         context.getExternalContext().getSessionMap(),
-                         _VIEW_CACHE_KEY + ".");
+        Map<String, PageState> stateMap = new SubKeyMap<PageState>(sessionMap,
+                                                                   _VIEW_CACHE_KEY + ".");
+
         // Sadly, we can't save just a SerializedView, because we should
         // save a serialized object, and SerializedView is a *non*-static
         // inner class of StateManager
@@ -318,12 +322,14 @@
         // clear out all of the previous PageStates' UIViewRoots and add this page
         // state as an active page state.  This is necessary to avoid UIViewRoots
         // laying around if the user navigates off of a page using a GET
-        synchronized(this)
+        synchronized(extContext.getSession(true))
         {
-          if (_activePageState != null)
-            _activePageState.clearViewRootState();
+          PageState activePageState = (PageState)sessionMap.get(_ACTIVE_PAGE_STATE_SESSION_KEY);
+
+          if (activePageState != null)
+            activePageState.clearViewRootState();
           
-          _activePageState = pageState;
+          sessionMap.put(_ACTIVE_PAGE_STATE_SESSION_KEY, pageState);
         }
         
         String requestToken = _getRequestTokenForResponse(context);
@@ -347,8 +353,7 @@
         else
         {
           // See if we should pin this new state to any old state
-          String pinnedToken = (String)
-            context.getExternalContext().getRequestMap().get(_PINNED_STATE_TOKEN_KEY);
+          String pinnedToken = (String)extContext.getRequestMap().get(_PINNED_STATE_TOKEN_KEY);
           token = cache.addNewEntry(pageState,
                                     stateMap,
                                     pinnedToken);
@@ -382,8 +387,7 @@
       view = new SerializedView(token, null);
       
       // And store the token for this request
-      context.getExternalContext().getRequestMap().put(_REQUEST_STATE_TOKEN_KEY,
-                                                       token);
+      extContext.getRequestMap().put(_REQUEST_STATE_TOKEN_KEY, token);
     }
     else
     {
@@ -1117,7 +1121,6 @@
   private       Boolean      _useViewRootCache;
   private       Boolean      _useApplicationViewCache;
   private       Boolean      _structureGeneratedByTemplate;
-  private       PageState    _activePageState;
 
   private static final int _DEFAULT_CACHE_SIZE = 15;
 
@@ -1140,6 +1143,9 @@
   private static final String _REUSE_REQUEST_TOKEN_FOR_RESPONSE_KEY =
     "org.apache.myfaces.trinidadinternal.application.REUSE_REQUEST_TOKEN_FOR_RESPONSE";
 
+  // key for saving the PageState for the last accessed view in this Session
+  private static final String _ACTIVE_PAGE_STATE_SESSION_KEY =
+              "org.apache.myfaces.trinidadinternal.application.StateManagerImp.ACTIVE_PAGE_STATE";
 
   private static final String _APPLICATION_CACHE_TOKEN = "_a_";
 



Mime
View raw message