myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject svn commit: r1071968 - in /myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl: scope/conversation/ util/
Date Fri, 18 Feb 2011 11:26:55 GMT
Author: gpetracek
Date: Fri Feb 18 11:26:54 2011
New Revision: 1071968

URL: http://svn.apache.org/viewvc?rev=1071968&view=rev
Log:
EXTCDI-131 store new view-id as early as possible

Modified:
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/WindowContextAwareViewHandler.java
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/WindowContextManagerObserver.java
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/util/ConversationUtils.java

Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/WindowContextAwareViewHandler.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/WindowContextAwareViewHandler.java?rev=1071968&r1=1071967&r2=1071968&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/WindowContextAwareViewHandler.java
(original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/WindowContextAwareViewHandler.java
Fri Feb 18 11:26:54 2011
@@ -20,12 +20,16 @@ package org.apache.myfaces.extensions.cd
 
 import org.apache.myfaces.extensions.cdi.jsf.impl.scope.conversation.spi.WindowHandler;
 import org.apache.myfaces.extensions.cdi.jsf.impl.util.ConversationUtils;
+import static org.apache.myfaces.extensions.cdi.jsf.impl.util.ConversationUtils.storeViewIdAsNewViewId;
 import org.apache.myfaces.extensions.cdi.core.api.Deactivatable;
+import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.WindowContext;
 import org.apache.myfaces.extensions.cdi.core.impl.util.ClassDeactivation;
+import org.apache.myfaces.extensions.cdi.core.impl.scope.conversation.spi.WindowContextManager;
 
 import javax.faces.application.ViewHandlerWrapper;
 import javax.faces.application.ViewHandler;
 import javax.faces.context.FacesContext;
+import javax.faces.component.UIViewRoot;
 
 /**
  * @author Gerhard Petracek
@@ -77,4 +81,32 @@ public class WindowContextAwareViewHandl
     {
         return ClassDeactivation.isClassActivated(getClass());
     }
+
+    @Override
+    public UIViewRoot restoreView(FacesContext facesContext, String viewId)
+    {
+        if(isWindowIdAvailable(facesContext))
+        {
+            WindowContext windowContext = ConversationUtils.getWindowContextManager().getCurrentWindowContext();
+
+            if(windowContext != null)
+            {
+                //see EXTCDI-131
+                storeViewIdAsNewViewId(windowContext, viewId);
+            }
+        }
+
+        return super.restoreView(facesContext, viewId);
+    }
+
+    /**
+     * check if the window-id has been restored before the restore-view phase
+     * @param facesContext current faces-context
+     * @return true if the window-id has been restored before, false otherwise
+     */
+    private boolean isWindowIdAvailable(FacesContext facesContext)
+    {
+        return facesContext.getExternalContext().getRequestMap()
+                        .containsKey(WindowContextManager.WINDOW_CONTEXT_ID_PARAMETER_KEY);
+    }
 }

Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/WindowContextManagerObserver.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/WindowContextManagerObserver.java?rev=1071968&r1=1071967&r2=1071968&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/WindowContextManagerObserver.java
(original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/WindowContextManagerObserver.java
Fri Feb 18 11:26:54 2011
@@ -84,7 +84,7 @@ final class WindowContextManagerObserver
             if(active)
             {
                 RequestCache.setCurrentWindowContext(windowContextManager.getWindowContext(windowId));
-                //just for supporting e.g. el-expressions
+                //don't remove it - e.g. needed as marker for the view-handler
                 phaseEvent.getFacesContext().getExternalContext().getRequestMap()
                         .put(WindowContextManager.WINDOW_CONTEXT_ID_PARAMETER_KEY, windowId);
             }

Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/util/ConversationUtils.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/util/ConversationUtils.java?rev=1071968&r1=1071967&r2=1071968&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/util/ConversationUtils.java
(original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/util/ConversationUtils.java
Fri Feb 18 11:26:54 2011
@@ -234,6 +234,11 @@ public class ConversationUtils
     public static void storeCurrentViewIdAsNewViewId(FacesContext facesContext, WindowContext
windowContext)
     {
         String newViewId = facesContext.getViewRoot().getViewId();
+        storeViewIdAsNewViewId(windowContext, newViewId);
+    }
+
+    public static void storeViewIdAsNewViewId(WindowContext windowContext, String newViewId)
+    {
         windowContext.setAttribute(NEW_VIEW_ID_KEY, newViewId);
     }
 



Mime
View raw message