You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by gp...@apache.org on 2010/12/03 00:40:11 UTC

svn commit: r1041647 - in /myfaces/extensions/cdi/trunk/jee-modules: jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/util/ jsf20-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf2/impl/scope/conversation/

Author: gpetracek
Date: Thu Dec  2 23:40:10 2010
New Revision: 1041647

URL: http://svn.apache.org/viewvc?rev=1041647&view=rev
Log:
EXTCDI-79 cleanup

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

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=1041647&r1=1041646&r2=1041647&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 Thu Dec  2 23:40:10 2010
@@ -264,6 +264,9 @@ public class ConversationUtils
         return null;
     }
 
+    /**
+     * Needed for server-side window-handler and client-side window handler for supporting postbacks
+     */
     public static void addWindowContextIdHolderComponent()
     {
         FacesContext facesContext = FacesContext.getCurrentInstance();
@@ -428,4 +431,24 @@ public class ConversationUtils
     {
         return !editableWindowContext.isActive() || editableWindowContext.getConversations().isEmpty();
     }
+
+    /**
+     * alternative to {@link ConversationUtils#getExistingWindowIdSet} because it might be deactivated...
+     *
+     * @param windowContextManager current windowContextManager
+     * @param windowId windowId in question
+     * @return true if the window is known and active, false otherwise
+     */
+    public static boolean isWindowActive(EditableWindowContextManager windowContextManager, String windowId)
+    {
+        for (EditableWindowContext editableWindowContext : windowContextManager.getWindowContexts())
+        {
+            if (windowId.equals(editableWindowContext.getId()) && editableWindowContext.isActive())
+            {
+                return true;
+            }
+        }
+
+        return false;
+    }
 }

Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf20-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf2/impl/scope/conversation/ClientSideWindowHandler.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf20-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf2/impl/scope/conversation/ClientSideWindowHandler.java?rev=1041647&r1=1041646&r2=1041647&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf20-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf2/impl/scope/conversation/ClientSideWindowHandler.java (original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf20-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf2/impl/scope/conversation/ClientSideWindowHandler.java Thu Dec  2 23:40:10 2010
@@ -21,9 +21,9 @@ package org.apache.myfaces.extensions.cd
 import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.config.WindowContextConfig;
 import org.apache.myfaces.extensions.cdi.core.impl.scope.conversation.spi.WindowContextManager;
 import org.apache.myfaces.extensions.cdi.jsf.impl.scope.conversation.DefaultWindowHandler;
-import org.apache.myfaces.extensions.cdi.jsf.impl.scope.conversation.spi.EditableWindowContext;
 import org.apache.myfaces.extensions.cdi.jsf.impl.scope.conversation.spi.EditableWindowContextManager;
 import org.apache.myfaces.extensions.cdi.jsf.impl.util.JsfUtils;
+import org.apache.myfaces.extensions.cdi.jsf.impl.util.ConversationUtils;
 import org.apache.myfaces.extensions.cdi.jsf2.api.config.ClientInformation;
 import org.apache.myfaces.extensions.cdi.jsf2.impl.scope.conversation.spi.LifecycleAwareWindowHandler;
 
@@ -74,7 +74,7 @@ public class ClientSideWindowHandler ext
     @Override
     public String encodeURL(String url)
     {
-        if (clientInformation.isJavaScriptEnabled())
+        if (this.clientInformation.isJavaScriptEnabled())
         {
             // do not add the windowId
             return url;
@@ -89,7 +89,7 @@ public class ClientSideWindowHandler ext
     @Override
     public String restoreWindowId(ExternalContext externalContext)
     {
-        if (clientInformation.isJavaScriptEnabled())
+        if (this.clientInformation.isJavaScriptEnabled())
         {
             return (String) externalContext.getRequestMap().get(WindowContextManager.WINDOW_CONTEXT_ID_PARAMETER_KEY);
         }
@@ -119,10 +119,11 @@ public class ClientSideWindowHandler ext
         else
         {
             if (WindowContextManager.AUTOMATED_ENTRY_POINT_PARAMETER_KEY.equals(windowId)
-                    || !isWindowIdAlive(windowId))
+                    || !ConversationUtils.isWindowActive(this.windowContextManager, windowId))
             {
                 // no or invalid windowId --> create new one
-                windowId = windowContextManager.getCurrentWindowContext().getId();
+                // don't use createWindowId() the following call will ensure the max. window context count,...
+                windowId = this.windowContextManager.getCurrentWindowContext().getId();
 
                 // GET request with NEW windowId - send windowhandlerfilter.html to set and re-get the windowId
                 sendWindowHandlerHtml(externalContext, windowId);
@@ -141,7 +142,7 @@ public class ClientSideWindowHandler ext
     {
         // no POST request and javascript enabled
         // NOTE that for POST-requests the windowId is saved in the state (see WindowContextIdHolderComponent)
-        return !facesContext.isPostback() && clientInformation.isJavaScriptEnabled();
+        return !facesContext.isPostback() && this.clientInformation.isJavaScriptEnabled();
     }
 
     private void sendWindowHandlerHtml(ExternalContext externalContext, String windowId)
@@ -153,7 +154,7 @@ public class ClientSideWindowHandler ext
             httpResponse.setStatus(HttpServletResponse.SC_OK);
             httpResponse.setContentType("text/html");
 
-            String windowHandlerHtml = clientInformation.getWindowHandlerHtml();
+            String windowHandlerHtml = this.clientInformation.getWindowHandlerHtml();
 
             if (windowId == null)
             {
@@ -240,17 +241,4 @@ public class ClientSideWindowHandler ext
 
         return "";
     }
-
-    private boolean isWindowIdAlive(String windowId)
-    {
-        for (EditableWindowContext wc : windowContextManager.getWindowContexts())
-        {
-            if (windowId.equals(wc.getId()))
-            {
-                return true;
-            }
-        }
-
-        return false;
-    }
 }