myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r1461361 - in /myfaces/core/branches/2.2.x: client-window-example/src/main/java/org/apache/myfaces/example/clientWindow/ impl/src/main/java/org/apache/myfaces/config/ impl/src/main/java/org/apache/myfaces/config/element/ impl/src/main/java/...
Date Tue, 26 Mar 2013 22:54:31 GMT
Author: lu4242
Date: Tue Mar 26 22:54:30 2013
New Revision: 1461361

URL: http://svn.apache.org/r1461361
Log:
MYFACES-3588 window-id support (latest updates until final draft 2)

Added:
    myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/lifecycle/ClientWindowFactoryImpl.java
  (with props)
Modified:
    myfaces/core/branches/2.2.x/client-window-example/src/main/java/org/apache/myfaces/example/clientWindow/DisableClientWindow.java
    myfaces/core/branches/2.2.x/client-window-example/src/main/java/org/apache/myfaces/example/clientWindow/EnableClientWindow.java
    myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/config/DefaultFacesConfigurationProvider.java
    myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/config/FacesConfigDispenser.java
    myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
    myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/config/element/FacesConfigData.java
    myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/config/element/Factory.java
    myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigDispenserImpl.java
    myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigUnmarshallerImpl.java
    myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/Factory.java
    myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/context/servlet/ServletExternalContextImpl.java
    myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/lifecycle/LifecycleImpl.java

Modified: myfaces/core/branches/2.2.x/client-window-example/src/main/java/org/apache/myfaces/example/clientWindow/DisableClientWindow.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.2.x/client-window-example/src/main/java/org/apache/myfaces/example/clientWindow/DisableClientWindow.java?rev=1461361&r1=1461360&r2=1461361&view=diff
==============================================================================
--- myfaces/core/branches/2.2.x/client-window-example/src/main/java/org/apache/myfaces/example/clientWindow/DisableClientWindow.java
(original)
+++ myfaces/core/branches/2.2.x/client-window-example/src/main/java/org/apache/myfaces/example/clientWindow/DisableClientWindow.java
Tue Mar 26 22:54:30 2013
@@ -22,7 +22,6 @@ import java.io.IOException;
 import javax.faces.component.FacesComponent;
 import javax.faces.component.UINamingContainer;
 import javax.faces.context.FacesContext;
-import javax.faces.lifecycle.ClientWindow;
 
 /**
  *
@@ -35,7 +34,7 @@ public class DisableClientWindow extends
     @Override
     public void encodeBegin(FacesContext context) throws IOException
     {
-        ClientWindow.disableClientWindowRenderMode(context);
+        context.getExternalContext().getClientWindow().disableClientWindowRenderMode(context);
         super.encodeBegin(context);
     }
 

Modified: myfaces/core/branches/2.2.x/client-window-example/src/main/java/org/apache/myfaces/example/clientWindow/EnableClientWindow.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.2.x/client-window-example/src/main/java/org/apache/myfaces/example/clientWindow/EnableClientWindow.java?rev=1461361&r1=1461360&r2=1461361&view=diff
==============================================================================
--- myfaces/core/branches/2.2.x/client-window-example/src/main/java/org/apache/myfaces/example/clientWindow/EnableClientWindow.java
(original)
+++ myfaces/core/branches/2.2.x/client-window-example/src/main/java/org/apache/myfaces/example/clientWindow/EnableClientWindow.java
Tue Mar 26 22:54:30 2013
@@ -22,7 +22,6 @@ import java.io.IOException;
 import javax.faces.component.FacesComponent;
 import javax.faces.component.UINamingContainer;
 import javax.faces.context.FacesContext;
-import javax.faces.lifecycle.ClientWindow;
 
 /**
  *
@@ -35,7 +34,7 @@ public class EnableClientWindow extends 
     @Override
     public void encodeBegin(FacesContext context) throws IOException
     {
-        ClientWindow.enableClientWindowRenderMode(context);
+        context.getExternalContext().getClientWindow().enableClientWindowRenderMode(context);
         super.encodeBegin(context);
     }
 }

Modified: myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/config/DefaultFacesConfigurationProvider.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/config/DefaultFacesConfigurationProvider.java?rev=1461361&r1=1461360&r2=1461361&view=diff
==============================================================================
--- myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/config/DefaultFacesConfigurationProvider.java
(original)
+++ myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/config/DefaultFacesConfigurationProvider.java
Tue Mar 26 22:54:30 2013
@@ -237,7 +237,18 @@ public class DefaultFacesConfigurationPr
                     {
                         factory.addViewDeclarationLanguageFactory(className);
                     }
-                    
+                    else if(factoryName.equals(FactoryFinder.FLASH_FACTORY)) 
+                    {
+                        factory.addFlashFactory(className);
+                    }
+                    else if(factoryName.equals(FactoryFinder.FLOW_HANDLER_FACTORY)) 
+                    {
+                        factory.addFlowHandlerFactory(className);
+                    }
+                    else if(factoryName.equals(FactoryFinder.CLIENT_WINDOW_FACTORY)) 
+                    {
+                        factory.addClientWindowFactory(className);
+                    }
                     else
                     {
                         throw new IllegalStateException("Unexpected factory name " + factoryName);

Modified: myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/config/FacesConfigDispenser.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/config/FacesConfigDispenser.java?rev=1461361&r1=1461360&r2=1461361&view=diff
==============================================================================
--- myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/config/FacesConfigDispenser.java
(original)
+++ myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/config/FacesConfigDispenser.java
Tue Mar 26 22:54:30 2013
@@ -117,5 +117,13 @@ public abstract class FacesConfigDispens
     public void feedFlashFactory(String factoryClassName)
     {
     }
+    
+    /**
+     * @since 2.2
+     * @param factoryClassName 
+     */
+    public void feedClientWindowFactory(String factoryClassName)
+    {
+    }
 
 }

Modified: myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java?rev=1461361&r1=1461360&r2=1461361&view=diff
==============================================================================
--- myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
(original)
+++ myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
Tue Mar 26 22:54:30 2013
@@ -94,6 +94,7 @@ import org.apache.myfaces.context.servle
 import org.apache.myfaces.el.DefaultPropertyResolver;
 import org.apache.myfaces.el.VariableResolverImpl;
 import org.apache.myfaces.el.unified.ResolverBuilderBase;
+import org.apache.myfaces.lifecycle.ClientWindowFactoryImpl;
 import org.apache.myfaces.lifecycle.LifecycleFactoryImpl;
 import org.apache.myfaces.renderkit.RenderKitFactoryImpl;
 import org.apache.myfaces.renderkit.html.HtmlRenderKitImpl;
@@ -143,6 +144,7 @@ public class FacesConfigurator
     private static final String DEFAULT_TAG_HANDLER_DELEGATE_FACTORY = TagHandlerDelegateFactoryImpl.class.getName();
     private static final String DEFAULT_FACELET_CACHE_FACTORY = FaceletCacheFactoryImpl.class.getName();
     private static final String DEFAULT_FLASH_FACTORY = ServletFlashFactoryImpl.class.getName();
+    private static final String DEFAULT_CLIENT_WINDOW_FACTORY = ClientWindowFactoryImpl.class.getName();
     private static final String DEFAULT_FACES_CONFIG = "/WEB-INF/faces-config.xml";
 
     private final ExternalContext _externalContext;
@@ -495,7 +497,8 @@ public class FacesConfigurator
                 DEFAULT_FACELET_CACHE_FACTORY);
         setFactories(FactoryFinder.FLASH_FACTORY, dispenser.getFlashFactoryIterator(),
                 DEFAULT_FLASH_FACTORY);
-
+        setFactories(FactoryFinder.CLIENT_WINDOW_FACTORY, dispenser.getClientWindowFactoryIterator(),
+                DEFAULT_CLIENT_WINDOW_FACTORY);
     }
 
     private void setFactories(String factoryName, Collection<String> factories, String
defaultFactory)

Modified: myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/config/element/FacesConfigData.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/config/element/FacesConfigData.java?rev=1461361&r1=1461360&r2=1461361&view=diff
==============================================================================
--- myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/config/element/FacesConfigData.java
(original)
+++ myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/config/element/FacesConfigData.java
Tue Mar 26 22:54:30 2013
@@ -84,6 +84,11 @@ public abstract class FacesConfigData im
     {
         return Collections.emptyList();
     }
+    
+    public Collection<String> getClientWindowFactoryIterator()
+    {
+        return Collections.emptyList();
+    }
 
     /** @return Iterator over ActionListener class names (in reverse order!) */
     public abstract Collection<String> getActionListenerIterator();

Modified: myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/config/element/Factory.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/config/element/Factory.java?rev=1461361&r1=1461360&r2=1461361&view=diff
==============================================================================
--- myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/config/element/Factory.java
(original)
+++ myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/config/element/Factory.java
Tue Mar 26 22:54:30 2013
@@ -57,8 +57,30 @@ public abstract class Factory implements
         return Collections.emptyList();
     }
     
+    /**
+     * @since 2.2
+     * @return 
+     */
     public List<String> getFlashFactory()
     {
         return Collections.emptyList();
     }
+    
+    /**
+     * @since 2.2
+     * @return 
+     */
+    public List<String> getFlowHandlerFactory()
+    {
+        return Collections.emptyList();
+    }
+
+    /**
+     * @since 2.2
+     * @return 
+     */
+    public List<String> getClientWindowFactory()
+    {
+        return Collections.emptyList();
+    }
 }

Modified: myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigDispenserImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigDispenserImpl.java?rev=1461361&r1=1461360&r2=1461361&view=diff
==============================================================================
--- myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigDispenserImpl.java
(original)
+++ myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigDispenserImpl.java
Tue Mar 26 22:54:30 2013
@@ -70,6 +70,7 @@ public class DigesterFacesConfigDispense
     private List<String> visitContextFactories = new ArrayList<String>();
     private List<String> faceletCacheFactories = new ArrayList<String>();
     private List<String> flashFactories = new ArrayList<String>();
+    private List<String> clientWindowFactories = new ArrayList<String>();
     
     private String defaultRenderKitId;
     private String messageBundle;
@@ -140,6 +141,7 @@ public class DigesterFacesConfigDispense
             visitContextFactories.addAll(factory.getVisitContextFactory());
             faceletCacheFactories.addAll(factory.getFaceletCacheFactory());
             flashFactories.addAll(factory.getFlashFactory());
+            clientWindowFactories.addAll(factory.getClientWindowFactory());
         }
 
         components.putAll(config.getComponents());
@@ -721,6 +723,18 @@ public class DigesterFacesConfigDispense
     }
 
     @Override
+    public void feedClientWindowFactory(String factoryClassName)
+    {
+        clientWindowFactories.add(factoryClassName);
+    }
+
+    @Override
+    public Collection<String> getClientWindowFactoryIterator()
+    {
+        return clientWindowFactories;
+    }
+    
+    @Override
     public Collection<FacesFlowDefinition> getFacesFlowDefinitions()
     {
         return facesFlowDefinitions;

Modified: myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigUnmarshallerImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigUnmarshallerImpl.java?rev=1461361&r1=1461360&r2=1461361&view=diff
==============================================================================
--- myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigUnmarshallerImpl.java
(original)
+++ myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/config/impl/digester/DigesterFacesConfigUnmarshallerImpl.java
Tue Mar 26 22:54:30 2013
@@ -140,6 +140,7 @@ public class DigesterFacesConfigUnmarsha
         // 2.1 specific end
         // 2.2 specific start
         digester.addCallMethod("faces-config/factory/flash-factory", "addFlashFactory", 0);
+        // Note there is no client-window-factory, this factory can be set only using SPI.
         // 2.2 specific end
 
         digester.addObjectCreate("faces-config/factory", Factory.class);

Modified: myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/Factory.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/Factory.java?rev=1461361&r1=1461360&r2=1461361&view=diff
==============================================================================
--- myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/Factory.java
(original)
+++ myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/config/impl/digester/elements/Factory.java
Tue Mar 26 22:54:30 2013
@@ -38,7 +38,9 @@ public class Factory extends org.apache.
     private List<String> tagHandlerDelegateFactories = new ArrayList<String>();
     private List<String> visitContextFactories = new ArrayList<String>();
     private List<String> faceletCacheFactories = new ArrayList<String>();
+    private List<String> flowHandlerFactories = new ArrayList<String>();
     private List<String> flashFactories = new ArrayList<String>();
+    private List<String> clientWindowFactories = new ArrayList<String>();
 
     public void addApplicationFactory(String factory)
     {
@@ -95,6 +97,21 @@ public class Factory extends org.apache.
         faceletCacheFactories.add(factory);
     }
 
+    public void addFlashFactory(String factory)
+    {
+        flashFactories.add(factory);
+    }
+    
+    public void addFlowHandlerFactory(String factory)
+    {
+        flowHandlerFactories.add(factory);
+    }
+
+    public void addClientWindowFactory(String factory)
+    {
+        clientWindowFactories.add(factory);
+    }
+    
     public List<String> getApplicationFactory()
     {
         return applicationFactories;
@@ -156,5 +173,16 @@ public class Factory extends org.apache.
     {
         return flashFactories;
     }
-    
+
+    @Override
+    public List<String> getFlowHandlerFactory()
+    {
+        return flowHandlerFactories;
+    }
+
+    @Override
+    public List<String> getClientWindowFactory()
+    {
+        return clientWindowFactories;
+    }
 }

Modified: myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/context/servlet/ServletExternalContextImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/context/servlet/ServletExternalContextImpl.java?rev=1461361&r1=1461360&r2=1461361&view=diff
==============================================================================
--- myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/context/servlet/ServletExternalContextImpl.java
(original)
+++ myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/context/servlet/ServletExternalContextImpl.java
Tue Mar 26 22:54:30 2013
@@ -353,12 +353,12 @@ public final class ServletExternalContex
     private String encodeWindowId(String encodedUrl)
     {
         FacesContext facesContext = FacesContext.getCurrentInstance();
-        if (ClientWindow.isClientWindowRenderModeEnabled(facesContext))
+        ClientWindow window = facesContext.getExternalContext().getClientWindow();
+        if (window != null)
         {
-            //TODO: Use StringBuilder or some optimization.
-            ClientWindow window = facesContext.getExternalContext().getClientWindow();
-            if (window != null)
+            if (window.isClientWindowRenderModeEnabled(facesContext))
             {
+            //TODO: Use StringBuilder or some optimization.
                 Map<String, String> map = window.getQueryURLParameters(facesContext);
                 if (map != null)
                 {
@@ -847,11 +847,11 @@ public final class ServletExternalContex
         }
         
         FacesContext facesContext = FacesContext.getCurrentInstance();
-        if (ClientWindow.isClientWindowRenderModeEnabled(facesContext))
+        ClientWindow window = facesContext.getExternalContext().getClientWindow();
+        if (window != null)
         {
             //TODO: Use StringBuilder or some optimization.
-            ClientWindow window = facesContext.getExternalContext().getClientWindow();
-            if (window != null)
+            if (window.isClientWindowRenderModeEnabled(facesContext))
             {
                 Map<String, String> map = window.getQueryURLParameters(facesContext);
                 if (map != null)

Added: myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/lifecycle/ClientWindowFactoryImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/lifecycle/ClientWindowFactoryImpl.java?rev=1461361&view=auto
==============================================================================
--- myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/lifecycle/ClientWindowFactoryImpl.java
(added)
+++ myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/lifecycle/ClientWindowFactoryImpl.java
Tue Mar 26 22:54:30 2013
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.lifecycle;
+
+import javax.faces.context.FacesContext;
+import javax.faces.lifecycle.ClientWindow;
+import javax.faces.lifecycle.ClientWindowFactory;
+import org.apache.myfaces.shared.util.WebConfigParamUtils;
+
+/**
+ *
+ * @since 2.2
+ * @author Leonardo Uribe
+ */
+public class ClientWindowFactoryImpl extends ClientWindowFactory
+{
+    private String windowMode;
+    private TokenGenerator windowTokenGenerator;
+    private ClientConfig clientConfig;
+    private WindowContextConfig windowContextConfig;
+    
+    private static final String WINDOW_MODE_NONE = "none";
+    private static final String WINDOW_MODE_URL = "url";
+    private static final String WINDOW_MODE_CLIENT = "client";
+
+    public ClientWindowFactoryImpl()
+    {
+        windowTokenGenerator = new TokenGenerator();
+        clientConfig = new ClientConfig();
+        windowContextConfig = new WindowContextConfig();
+    }
+
+    @Override
+    public ClientWindow getClientWindow(FacesContext facesContext)
+    {
+        if (WINDOW_MODE_NONE.equals(getWindowMode(facesContext)))
+        {
+            //No need to do anything
+            return null;
+        }
+        else
+        {
+            if (WINDOW_MODE_URL.equals(getWindowMode(facesContext)))
+            {
+                return new UrlClientWindow(windowTokenGenerator);
+            }
+            else if (WINDOW_MODE_CLIENT.equals(getWindowMode(facesContext)))
+            {
+                //clientWindow = new DefaultClientWindow(windowTokenGenerator);
+                return new CODIClientSideWindow(windowTokenGenerator,
+                        windowContextConfig, clientConfig);
+            }
+            else
+            {
+                return null;
+            }
+        }
+    }
+    
+    private String getWindowMode(FacesContext context)
+    {
+        if (windowMode == null)
+        {
+            windowMode = WebConfigParamUtils.getStringInitParameter(
+                    context.getExternalContext(), 
+                    ClientWindow.CLIENT_WINDOW_MODE_PARAM_NAME, WINDOW_MODE_NONE);
+        }
+        return windowMode;
+    }
+
+}

Propchange: myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/lifecycle/ClientWindowFactoryImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/lifecycle/LifecycleImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/lifecycle/LifecycleImpl.java?rev=1461361&r1=1461360&r2=1461361&view=diff
==============================================================================
--- myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/lifecycle/LifecycleImpl.java
(original)
+++ myfaces/core/branches/2.2.x/impl/src/main/java/org/apache/myfaces/lifecycle/LifecycleImpl.java
Tue Mar 26 22:54:30 2013
@@ -24,6 +24,7 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import javax.faces.FacesException;
+import javax.faces.FactoryFinder;
 import javax.faces.application.ProjectStage;
 import javax.faces.context.FacesContext;
 import javax.faces.context.Flash;
@@ -32,10 +33,10 @@ import javax.faces.event.ExceptionQueued
 import javax.faces.event.PhaseId;
 import javax.faces.event.PhaseListener;
 import javax.faces.lifecycle.ClientWindow;
+import javax.faces.lifecycle.ClientWindowFactory;
 import javax.faces.lifecycle.Lifecycle;
 
 import org.apache.myfaces.config.FacesConfigurator;
-import org.apache.myfaces.shared.util.WebConfigParamUtils;
 import org.apache.myfaces.shared_impl.webapp.webxml.WebXml;
 import org.apache.myfaces.util.DebugUtils;
 
@@ -91,15 +92,8 @@ public class LifecycleImpl extends Lifec
      */
     //private PhaseListener[] _phaseListenerArray = null;
     
-    private String windowMode;
-    private TokenGenerator windowTokenGenerator;
-    private ClientConfig clientConfig;
-    private WindowContextConfig windowContextConfig;
+    private ClientWindowFactory clientWindowFactory;
     
-    private static final String WINDOW_MODE_NONE = "none";
-    private static final String WINDOW_MODE_URL = "url";
-    private static final String WINDOW_MODE_CLIENT = "client";
-
     public LifecycleImpl()
     {
         // hide from public access
@@ -107,50 +101,28 @@ public class LifecycleImpl extends Lifec
                 new ProcessValidationsExecutor(), new UpdateModelValuesExecutor(), new InvokeApplicationExecutor()
};
 
         renderExecutor = new RenderResponseExecutor();
-        windowTokenGenerator = new TokenGenerator();
-        clientConfig = new ClientConfig();
-        windowContextConfig = new WindowContextConfig();
+        clientWindowFactory = (ClientWindowFactory) FactoryFinder.getFactory(FactoryFinder.CLIENT_WINDOW_FACTORY);
     }
     
-    private String getWindowMode(FacesContext context)
-    {
-        if (windowMode == null)
-        {
-            windowMode = WebConfigParamUtils.getStringInitParameter(
-                    context.getExternalContext(), 
-                    ClientWindow.CLIENT_WINDOW_MODE_PARAM_NAME, WINDOW_MODE_NONE);
-        }
-        return windowMode;
-    }
-
     @Override
     public void attachWindow(FacesContext facesContext)
     {
-        if (WINDOW_MODE_NONE.equals(getWindowMode(facesContext)))
+        ClientWindow clientWindow = facesContext.getExternalContext().getClientWindow();
+        if (clientWindow == null)
         {
-            //No need to do anything
-            return;
+            clientWindow = getClientWindowFactory().getClientWindow(facesContext);
         }
-        else
+        if (clientWindow != null)
         {
-            ClientWindow clientWindow = facesContext.getExternalContext().getClientWindow();
-            if (clientWindow == null)
-            {
-                if (WINDOW_MODE_URL.equals(getWindowMode(facesContext)))
-                {
-                    clientWindow = new UrlClientWindow(windowTokenGenerator);
-                }
-                else
-                {
-                    //clientWindow = new DefaultClientWindow(windowTokenGenerator);
-                    clientWindow = new CODIClientSideWindow(windowTokenGenerator,
-                            windowContextConfig, clientConfig);
-                }
-                clientWindow.decode(facesContext);
-                facesContext.getExternalContext().setClientWindow(clientWindow);
-            }
+            clientWindow.decode(facesContext);
+            facesContext.getExternalContext().setClientWindow(clientWindow);
         }
     }
+    
+    protected ClientWindowFactory getClientWindowFactory()
+    {
+        return clientWindowFactory;
+    }
 
     @Override
     public void execute(FacesContext facesContext) throws FacesException



Mime
View raw message