You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltaspike.apache.org by gp...@apache.org on 2013/11/01 20:19:28 UTC

git commit: DELTASPIKE-432 client-window adapter for jsf 2.2 (first draft)

Updated Branches:
  refs/heads/master 951a3b6c0 -> 4a3da4053


DELTASPIKE-432 client-window adapter for jsf 2.2 (first draft)


Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/4a3da405
Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/4a3da405
Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/4a3da405

Branch: refs/heads/master
Commit: 4a3da405381406e2b3236e86a77efa92aac1d983
Parents: 951a3b6
Author: gpetracek <gp...@apache.org>
Authored: Fri Nov 1 19:42:53 2013 +0100
Committer: gpetracek <gp...@apache.org>
Committed: Fri Nov 1 20:15:23 2013 +0100

----------------------------------------------------------------------
 .../jsf/api/config/JsfModuleConfig.java         |  18 ++
 .../spi/scope/window/ClientWindowConfig.java    |   5 +
 .../scope/window/DefaultClientWindowConfig.java |  23 +++
 .../DeltaSpikeLifecycleFactoryWrapper.java      |  22 +++
 .../request/DeltaSpikeLifecycleWrapper.java     |  11 ++
 .../JsfClientWindowAwareLifecycleWrapper.java   | 165 +++++++++++++++++++
 .../impl/scope/window/ClientWindowAdapter.java  |  69 ++++++++
 .../impl/scope/window/DefaultClientWindow.java  |  19 ++-
 deltaspike/modules/jsf/pom.xml                  |   3 +
 deltaspike/parent/pom.xml                       |   1 +
 10 files changed, 330 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/4a3da405/deltaspike/modules/jsf/api/src/main/java/org/apache/deltaspike/jsf/api/config/JsfModuleConfig.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/api/src/main/java/org/apache/deltaspike/jsf/api/config/JsfModuleConfig.java b/deltaspike/modules/jsf/api/src/main/java/org/apache/deltaspike/jsf/api/config/JsfModuleConfig.java
index b5b84b8..ee2c0a6 100644
--- a/deltaspike/modules/jsf/api/src/main/java/org/apache/deltaspike/jsf/api/config/JsfModuleConfig.java
+++ b/deltaspike/modules/jsf/api/src/main/java/org/apache/deltaspike/jsf/api/config/JsfModuleConfig.java
@@ -19,8 +19,10 @@
 package org.apache.deltaspike.jsf.api.config;
 
 import org.apache.deltaspike.core.api.config.DeltaSpikeConfig;
+import org.apache.deltaspike.core.util.ClassUtils;
 
 import javax.enterprise.context.ApplicationScoped;
+import javax.faces.context.FacesContext;
 
 /**
  * Config for all JSF specific configurations.
@@ -28,6 +30,9 @@ import javax.enterprise.context.ApplicationScoped;
 @ApplicationScoped
 public class JsfModuleConfig implements DeltaSpikeConfig
 {
+    public static final String CLIENT_WINDOW_CONFIG_KEY = "javax.faces.CLIENT_WINDOW_MODE";
+    public static final String CLIENT_WINDOW_CLASS_NAME = "javax.faces.lifecycle.ClientWindow";
+
     private static final long serialVersionUID = -487295181899986237L;
 
     protected JsfModuleConfig()
@@ -81,4 +86,17 @@ public class JsfModuleConfig implements DeltaSpikeConfig
     {
         return true;
     }
+
+    public boolean isDelegatedWindowHandlingEnabled()
+    {
+        if (ClassUtils.tryToLoadClassForName(CLIENT_WINDOW_CLASS_NAME) == null)
+        {
+            return false;
+        }
+
+        String configuredWindowHandling = FacesContext.getCurrentInstance().getExternalContext()
+                                .getInitParameter(CLIENT_WINDOW_CONFIG_KEY);
+
+        return !(configuredWindowHandling == null || "none".equalsIgnoreCase(configuredWindowHandling.trim()));
+    }
 }

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/4a3da405/deltaspike/modules/jsf/api/src/main/java/org/apache/deltaspike/jsf/spi/scope/window/ClientWindowConfig.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/api/src/main/java/org/apache/deltaspike/jsf/spi/scope/window/ClientWindowConfig.java b/deltaspike/modules/jsf/api/src/main/java/org/apache/deltaspike/jsf/spi/scope/window/ClientWindowConfig.java
index dd3c5db..2828bd4 100644
--- a/deltaspike/modules/jsf/api/src/main/java/org/apache/deltaspike/jsf/spi/scope/window/ClientWindowConfig.java
+++ b/deltaspike/modules/jsf/api/src/main/java/org/apache/deltaspike/jsf/spi/scope/window/ClientWindowConfig.java
@@ -49,6 +49,11 @@ public interface ClientWindowConfig
         LAZY,
 
         /**
+         * Delegates to the default window-handling of JSF 2.2+ (if configured)
+         */
+        DELEGATED,
+
+        /**
          * If you set this mode, you also need to provide an own {@link ClientWindow} implementation.
          */
         CUSTOM

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/4a3da405/deltaspike/modules/jsf/api/src/main/java/org/apache/deltaspike/jsf/spi/scope/window/DefaultClientWindowConfig.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/api/src/main/java/org/apache/deltaspike/jsf/spi/scope/window/DefaultClientWindowConfig.java b/deltaspike/modules/jsf/api/src/main/java/org/apache/deltaspike/jsf/spi/scope/window/DefaultClientWindowConfig.java
index a3bcf22..b2cb37d 100644
--- a/deltaspike/modules/jsf/api/src/main/java/org/apache/deltaspike/jsf/spi/scope/window/DefaultClientWindowConfig.java
+++ b/deltaspike/modules/jsf/api/src/main/java/org/apache/deltaspike/jsf/spi/scope/window/DefaultClientWindowConfig.java
@@ -18,6 +18,7 @@
  */
 package org.apache.deltaspike.jsf.spi.scope.window;
 
+import javax.annotation.PostConstruct;
 import javax.enterprise.context.SessionScoped;
 import javax.faces.context.FacesContext;
 import javax.inject.Inject;
@@ -30,6 +31,7 @@ import java.util.Map;
 import org.apache.deltaspike.core.api.projectstage.ProjectStage;
 import org.apache.deltaspike.core.util.ClassUtils;
 import org.apache.deltaspike.core.util.ExceptionUtils;
+import org.apache.deltaspike.jsf.api.config.JsfModuleConfig;
 
 /**
  * <p>Default implementation of {@link ClientWindowConfig}.
@@ -46,6 +48,8 @@ public class DefaultClientWindowConfig implements ClientWindowConfig, Serializab
      */
     public static final String COOKIE_NAME_NOSCRIPT_ENABLED = "deltaspikeNoScriptEnabled";
 
+    private static final long serialVersionUID = -708423418378550210L;
+
     /**
      * The location of the default windowhandler resource
      */
@@ -65,8 +69,18 @@ public class DefaultClientWindowConfig implements ClientWindowConfig, Serializab
     private String clientWindowtml;
 
     @Inject
+    private JsfModuleConfig jsfModuleConfig;
+
+    @Inject
     private ProjectStage projectStage;
 
+    private boolean useDelegatedWindowHandling;
+
+    @PostConstruct
+    protected void init()
+    {
+        this.useDelegatedWindowHandling = this.jsfModuleConfig.isDelegatedWindowHandlingEnabled();
+    }
 
     @Override
     public boolean isJavaScriptEnabled()
@@ -117,6 +131,10 @@ public class DefaultClientWindowConfig implements ClientWindowConfig, Serializab
     {
         if (!isJavaScriptEnabled())
         {
+            if (this.useDelegatedWindowHandling)
+            {
+                return ClientWindowRenderMode.DELEGATED;
+            }
             return ClientWindowRenderMode.NONE;
         }
 
@@ -132,6 +150,11 @@ public class DefaultClientWindowConfig implements ClientWindowConfig, Serializab
             return ClientWindowRenderMode.NONE;
         }
 
+        if (this.useDelegatedWindowHandling)
+        {
+            return ClientWindowRenderMode.DELEGATED;
+        }
+
         return ClientWindowRenderMode.CLIENTWINDOW;
     }
 

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/4a3da405/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/DeltaSpikeLifecycleFactoryWrapper.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/DeltaSpikeLifecycleFactoryWrapper.java b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/DeltaSpikeLifecycleFactoryWrapper.java
index a62483d..e415ba2 100644
--- a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/DeltaSpikeLifecycleFactoryWrapper.java
+++ b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/DeltaSpikeLifecycleFactoryWrapper.java
@@ -21,6 +21,9 @@ package org.apache.deltaspike.jsf.impl.listener.request;
 
 import org.apache.deltaspike.core.spi.activation.Deactivatable;
 import org.apache.deltaspike.core.util.ClassDeactivationUtils;
+import org.apache.deltaspike.core.util.ClassUtils;
+import org.apache.deltaspike.core.util.ExceptionUtils;
+import org.apache.deltaspike.jsf.api.config.JsfModuleConfig;
 
 import javax.faces.lifecycle.Lifecycle;
 import javax.faces.lifecycle.LifecycleFactory;
@@ -32,6 +35,8 @@ public class DeltaSpikeLifecycleFactoryWrapper extends LifecycleFactory implemen
 
     private final boolean deactivated;
 
+    private final boolean jsfVersionWithClientWindowDetected;
+
     /**
      * Constructor for wrapping the given {@link LifecycleFactory}
      *
@@ -41,6 +46,8 @@ public class DeltaSpikeLifecycleFactoryWrapper extends LifecycleFactory implemen
     {
         this.wrapped = wrapped;
         this.deactivated = !ClassDeactivationUtils.isActivated(getClass());
+        this.jsfVersionWithClientWindowDetected =
+                ClassUtils.tryToLoadClassForName(JsfModuleConfig.CLIENT_WINDOW_CLASS_NAME) != null;
     }
 
     @Override
@@ -58,6 +65,21 @@ public class DeltaSpikeLifecycleFactoryWrapper extends LifecycleFactory implemen
         {
             return result;
         }
+
+        if (this.jsfVersionWithClientWindowDetected)
+        {
+            Class<? extends Lifecycle> lifecycleWrapperClass = ClassUtils.tryToLoadClassForName(
+                    "org.apache.deltaspike.jsf.impl.listener.request.JsfClientWindowAwareLifecycleWrapper");
+            try
+            {
+                return lifecycleWrapperClass.getConstructor(new Class[] { Lifecycle.class })
+                        .newInstance(new DeltaSpikeLifecycleWrapper(result));
+            }
+            catch (Exception e)
+            {
+                throw ExceptionUtils.throwAsRuntimeException(e);
+            }
+        }
         return new DeltaSpikeLifecycleWrapper(result);
     }
 

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/4a3da405/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/DeltaSpikeLifecycleWrapper.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/DeltaSpikeLifecycleWrapper.java b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/DeltaSpikeLifecycleWrapper.java
index c9a0420..44ee9db 100644
--- a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/DeltaSpikeLifecycleWrapper.java
+++ b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/DeltaSpikeLifecycleWrapper.java
@@ -43,6 +43,11 @@ class DeltaSpikeLifecycleWrapper extends Lifecycle
         this.wrapped = wrapped;
     }
 
+    Lifecycle getWrapped()
+    {
+        return wrapped;
+    }
+
     @Override
     public void addPhaseListener(PhaseListener phaseListener)
     {
@@ -58,6 +63,12 @@ class DeltaSpikeLifecycleWrapper extends Lifecycle
     @Override
     public void execute(FacesContext facesContext)
     {
+        //can happen due to the window-handling of deltaspike
+        if (facesContext.getResponseComplete())
+        {
+            return;
+        }
+
         lazyInit();
 
         //TODO broadcastApplicationStartupBroadcaster();

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/4a3da405/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/JsfClientWindowAwareLifecycleWrapper.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/JsfClientWindowAwareLifecycleWrapper.java b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/JsfClientWindowAwareLifecycleWrapper.java
new file mode 100644
index 0000000..12a41ef
--- /dev/null
+++ b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/JsfClientWindowAwareLifecycleWrapper.java
@@ -0,0 +1,165 @@
+/*
+ * 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.deltaspike.jsf.impl.listener.request;
+
+import org.apache.deltaspike.core.api.provider.BeanProvider;
+import org.apache.deltaspike.core.util.ClassDeactivationUtils;
+import org.apache.deltaspike.core.util.ExceptionUtils;
+import org.apache.deltaspike.jsf.api.config.JsfModuleConfig;
+import org.apache.deltaspike.jsf.impl.scope.window.ClientWindowAdapter;
+import org.apache.deltaspike.jsf.spi.scope.window.ClientWindow;
+
+import javax.faces.context.FacesContext;
+import javax.faces.lifecycle.Lifecycle;
+import javax.faces.lifecycle.LifecycleWrapper;
+import java.lang.reflect.Field;
+
+@SuppressWarnings("UnusedDeclaration")
+public class JsfClientWindowAwareLifecycleWrapper extends LifecycleWrapper
+{
+    private final Lifecycle wrapped;
+
+    private volatile Boolean initialized;
+    private boolean delegateWindowHandling;
+
+    public JsfClientWindowAwareLifecycleWrapper(Lifecycle wrapped)
+    {
+        this.wrapped = wrapped;
+    }
+
+    public Lifecycle getWrapped()
+    {
+        return wrapped;
+    }
+
+    @Override
+    public void attachWindow(FacesContext facesContext)
+    {
+        if (this.initialized == null)
+        {
+            lazyInit();
+        }
+
+        if (this.delegateWindowHandling)
+        {
+            try
+            {
+                //the first wrapper is always DeltaSpikeLifecycleWrapper which can't extend from LifecycleWrapper
+                Lifecycle externalWrapper = ((DeltaSpikeLifecycleWrapper)this.wrapped).getWrapped();
+                delegateAttachWindow(facesContext, externalWrapper);
+            }
+            catch (Exception e)
+            {
+                try
+                {
+                    attachWindowOnUnwrappedInstance(facesContext, this.wrapped);
+                }
+                catch (Exception e1)
+                {
+                    throw ExceptionUtils.throwAsRuntimeException(e);
+                }
+            }
+        }
+        else
+        {
+            ClientWindow clientWindow = BeanProvider.getContextualReference(ClientWindow.class);
+            //trigger init - might lead to a redirect -> response-complete
+            String windowId = clientWindow.getWindowId(facesContext);
+
+            if (!facesContext.getResponseComplete() && !"default".equals(windowId))
+            {
+                facesContext.getExternalContext().setClientWindow(new ClientWindowAdapter(clientWindow));
+            }
+        }
+    }
+
+    private void attachWindowOnUnwrappedInstance(FacesContext facesContext, Lifecycle wrapped) throws Exception
+    {
+        Lifecycle wrappedLifecycle = null;
+
+        if (wrapped instanceof LifecycleWrapper)
+        {
+            wrappedLifecycle = ((LifecycleWrapper)wrapped).getWrapped();
+        }
+
+        //needed to support some libs which don't use LifecycleWrapper, because it's a jsf 2.2+ api
+        if (wrappedLifecycle == null)
+        {
+            for (Field field : wrapped.getClass().getDeclaredFields())
+            {
+                if (Lifecycle.class.isAssignableFrom(field.getType()))
+                {
+                    if (!field.isAccessible())
+                    {
+                        field.setAccessible(true);
+                    }
+                    wrappedLifecycle = (Lifecycle)field.get(wrapped);
+                    break;
+                }
+            }
+        }
+
+        if (wrappedLifecycle != null)
+        {
+            try
+            {
+                delegateAttachWindow(facesContext, wrappedLifecycle);
+            }
+            catch (Exception e)
+            {
+                attachWindowOnUnwrappedInstance(facesContext, wrappedLifecycle);
+            }
+        }
+    }
+
+    private static void delegateAttachWindow(FacesContext facesContext, Lifecycle lifecycle) throws Exception
+    {
+        //if there is an external wrapper (e.g. in case of other libs), we have to check
+        //the version of javax.faces.lifecycle.Lifecycle (>= or < v2.2)
+        //without the check and an old lib (in the classpath) #attachWindow would get ignored without exception
+        if (lifecycle instanceof LifecycleWrapper /*autom. provides #attachWindow*/ ||
+                lifecycle.getClass().getDeclaredMethod("attachWindow", FacesContext.class) != null)
+        {
+            lifecycle.attachWindow(facesContext);
+        }
+    }
+
+    private void lazyInit()
+    {
+        if (this.initialized == null)
+        {
+            init();
+        }
+    }
+
+    private synchronized void init()
+    {
+        // switch into paranoia mode
+        if (initialized == null)
+        {
+            if (ClassDeactivationUtils.isActivated(BeforeAfterJsfRequestBroadcaster.class))
+            {
+                delegateWindowHandling =
+                    BeanProvider.getContextualReference(JsfModuleConfig.class).isDelegatedWindowHandlingEnabled();
+            }
+
+            initialized = true;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/4a3da405/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/window/ClientWindowAdapter.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/window/ClientWindowAdapter.java b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/window/ClientWindowAdapter.java
new file mode 100644
index 0000000..b2d3c73
--- /dev/null
+++ b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/window/ClientWindowAdapter.java
@@ -0,0 +1,69 @@
+/*
+ * 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.deltaspike.jsf.impl.scope.window;
+
+import javax.faces.context.FacesContext;
+import javax.faces.lifecycle.ClientWindow;
+import java.util.Collections;
+import java.util.Map;
+
+/**
+ * This adapter supports two use-cases:
+ * #1: Using the window-handling of DeltaSpike also for JSF internals like state-handling
+ * #2: Using the window-handling of JSF for DeltaSpike (if the corresponding JSF-config is available)
+ */
+public class ClientWindowAdapter extends ClientWindow
+{
+    private final org.apache.deltaspike.jsf.spi.scope.window.ClientWindow window;
+
+    public ClientWindowAdapter(org.apache.deltaspike.jsf.spi.scope.window.ClientWindow window)
+    {
+        this.window = window;
+    }
+
+    public static String getWindowIdFromJsf(FacesContext facesContext)
+    {
+        ClientWindow clientWindow = facesContext.getExternalContext().getClientWindow();
+
+        if (clientWindow != null)
+        {
+            return clientWindow.getId();
+        }
+        return null;
+    }
+
+    @Override
+    public void decode(FacesContext context)
+    {
+        //currently not needed by the window-handling of DeltaSpike
+    }
+
+    @Override
+    public String getId()
+    {
+        return this.window.getWindowId(FacesContext.getCurrentInstance());
+    }
+
+    @Override
+    public Map<String, String> getQueryURLParameters(FacesContext context)
+    {
+        //currently not needed by the window-handling of DeltaSpike
+        return Collections.emptyMap();
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/4a3da405/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/window/DefaultClientWindow.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/window/DefaultClientWindow.java b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/window/DefaultClientWindow.java
index 3118502..dcc7262 100644
--- a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/window/DefaultClientWindow.java
+++ b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/window/DefaultClientWindow.java
@@ -60,14 +60,10 @@ public class DefaultClientWindow implements ClientWindow
     public static final String AUTOMATED_ENTRY_POINT_PARAMETER_KEY = "automatedEntryPoint";
 
     /**
-     * The parameter for the windowId for GET requests
-     */
-    public static final String DELTASPIKE_WINDOW_ID_PARAM = "windowId";
-
-    /**
      * The parameter for the windowId for POST requests
      */
     public static final String DELTASPIKE_WINDOW_ID_POST_PARAM = "dsPostWindowId";
+    public static final String JSF_WINDOW_ID_POST_PARAM = "javax.faces.ClientWindow";
 
     private static final Logger logger = Logger.getLogger(DefaultClientWindow.class.getName());
 
@@ -102,12 +98,18 @@ public class DefaultClientWindow implements ClientWindow
     @Override
     public String getWindowId(FacesContext facesContext)
     {
-        if (ClientWindowRenderMode.NONE.equals(clientWindowConfig.getClientWindowRenderMode(facesContext)))
+        ClientWindowRenderMode clientWindowRenderMode = clientWindowConfig.getClientWindowRenderMode(facesContext);
+        if (ClientWindowRenderMode.NONE.equals(clientWindowRenderMode))
         {
             // if this request should not get any window detection then we are done
             return DEFAULT_WINDOW_ID;
         }
 
+        if (ClientWindowRenderMode.DELEGATED.equals(clientWindowRenderMode))
+        {
+            return ClientWindowAdapter.getWindowIdFromJsf(facesContext);
+        }
+
         if (facesContext.isPostback())
         {
             // for POST we read the windowId from the WindowIdHolderComponent in our ViewRoot
@@ -163,6 +165,11 @@ public class DefaultClientWindow implements ClientWindow
     {
         Map<String, String> requestParams = facesContext.getExternalContext().getRequestParameterMap();
         String windowId = requestParams.get(DELTASPIKE_WINDOW_ID_POST_PARAM);
+
+        if (windowId == null)
+        {
+            windowId = requestParams.get(JSF_WINDOW_ID_POST_PARAM);
+        }
         return windowId;
     }
 

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/4a3da405/deltaspike/modules/jsf/pom.xml
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/pom.xml b/deltaspike/modules/jsf/pom.xml
index 214eeab..06a79b3 100644
--- a/deltaspike/modules/jsf/pom.xml
+++ b/deltaspike/modules/jsf/pom.xml
@@ -55,6 +55,9 @@
         <dependency>
             <groupId>org.apache.myfaces.core</groupId>
             <artifactId>myfaces-api</artifactId>
+            <!-- just needed for compiling >optional< classes for jsf 2.2
+                 jsf 2.0 and 2.1 compatibility is ensured via test-cases -->
+            <version>${myfaces22.version}</version>
             <scope>provided</scope>
         </dependency>
     </dependencies>

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/4a3da405/deltaspike/parent/pom.xml
----------------------------------------------------------------------
diff --git a/deltaspike/parent/pom.xml b/deltaspike/parent/pom.xml
index fb9c0ea..6d1a6b8 100644
--- a/deltaspike/parent/pom.xml
+++ b/deltaspike/parent/pom.xml
@@ -57,6 +57,7 @@
 
         <!-- JSF-2.0 implementations-->
         <myfaces2.version>2.0.14</myfaces2.version>
+        <myfaces22.version>2.2.0-beta</myfaces22.version>
         <myfaces2.version.current>2.1.8</myfaces2.version.current>
         <mojarra2.version>2.0.3-b03</mojarra2.version>