deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tandrasc...@apache.org
Subject deltaspike git commit: DELTASPIKE-946 Prevent jfwid rendering
Date Mon, 06 Jul 2015 21:31:18 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master 70c42ca9d -> 07f0bdd7b


DELTASPIKE-946 Prevent jfwid rendering

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

Branch: refs/heads/master
Commit: 07f0bdd7b02ca9c5c2adbadd2f889cd1a5c7a695
Parents: 70c42ca
Author: Thomas Andraschko <tandraschko@apache.org>
Authored: Mon Jul 6 23:29:04 2015 +0200
Committer: Thomas Andraschko <tandraschko@apache.org>
Committed: Mon Jul 6 23:29:04 2015 +0200

----------------------------------------------------------------------
 .../window/DisableClientWindowHtmlRenderer.java | 23 +++++++----
 .../JsfClientWindowAwareLifecycleWrapper.java   | 30 ++++++++++-----
 .../impl/scope/window/ClientWindowAdapter.java  | 40 +-------------------
 .../strategy/AbstractClientWindowStrategy.java  | 26 -------------
 4 files changed, 37 insertions(+), 82 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/07f0bdd7/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/component/window/DisableClientWindowHtmlRenderer.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/component/window/DisableClientWindowHtmlRenderer.java
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/component/window/DisableClientWindowHtmlRenderer.java
index 29ddd50..86901e8 100644
--- a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/component/window/DisableClientWindowHtmlRenderer.java
+++ b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/component/window/DisableClientWindowHtmlRenderer.java
@@ -25,7 +25,6 @@ import javax.faces.render.FacesRenderer;
 import javax.faces.render.Renderer;
 import org.apache.deltaspike.core.api.provider.BeanProvider;
 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;
 
 @FacesRenderer(componentFamily = DisableClientWindowComponent.COMPONENT_FAMILY,
@@ -42,33 +41,41 @@ public class DisableClientWindowHtmlRenderer extends Renderer
     {
         lazyInit();
         
-        boolean clientWindowRenderModeEnabled = clientWindow.isClientWindowRenderModeEnabled(context);
+        boolean dsClientWindowRenderModeEnabled = clientWindow.isClientWindowRenderModeEnabled(context);
+        boolean jsfClientWindowRenderModeEnabled = false;
         
         if (jsfModuleConfig.isJsf22Available())
         {
-            Boolean jsfClientWindowRenderModeEnabled =
-                    ClientWindowAdapter.isJsf22ClientWindowRenderModeEnabled(context);
-            if (jsfClientWindowRenderModeEnabled != null)
+            if (context.getExternalContext().getClientWindow() != null)
             {
-                clientWindowRenderModeEnabled = clientWindowRenderModeEnabled || jsfClientWindowRenderModeEnabled;
+                jsfClientWindowRenderModeEnabled =
+                        context.getExternalContext().getClientWindow().isClientWindowRenderModeEnabled(context);
             }
         }
         
         try
         {
-            if (clientWindowRenderModeEnabled)
+            if (dsClientWindowRenderModeEnabled)
             {
                 clientWindow.disableClientWindowRenderMode(context);
             }
+            if (jsfClientWindowRenderModeEnabled)
+            {
+                context.getExternalContext().getClientWindow().disableClientWindowRenderMode(context);
+            }
 
             super.encodeChildren(context, component);
         }
         finally
         {
-            if (clientWindowRenderModeEnabled)
+            if (dsClientWindowRenderModeEnabled)
             {
                 clientWindow.enableClientWindowRenderMode(context);
             }
+            if (jsfClientWindowRenderModeEnabled)
+            {
+                context.getExternalContext().getClientWindow().enableClientWindowRenderMode(context);
+            }
         }
     }
     

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/07f0bdd7/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
index 1bb6db4..a482f22 100644
--- 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
@@ -29,6 +29,7 @@ import javax.faces.context.FacesContext;
 import javax.faces.lifecycle.Lifecycle;
 import javax.faces.lifecycle.LifecycleWrapper;
 import java.lang.reflect.Field;
+import javax.faces.FacesException;
 
 //ATTENTION: don't rename/move this class as long as we need the workaround in impl-ee6
 //(further details are available at: DELTASPIKE-655 and DELTASPIKE-659)
@@ -46,6 +47,7 @@ public class JsfClientWindowAwareLifecycleWrapper extends LifecycleWrapper
         this.wrapped = wrapped;
     }
 
+    @Override
     public Lifecycle getWrapped()
     {
         return wrapped;
@@ -54,10 +56,7 @@ public class JsfClientWindowAwareLifecycleWrapper extends LifecycleWrapper
     @Override
     public void attachWindow(FacesContext facesContext)
     {
-        if (this.initialized == null)
-        {
-            lazyInit();
-        }
+        lazyInit();
 
         if (this.delegateWindowHandling)
         {
@@ -87,8 +86,7 @@ public class JsfClientWindowAwareLifecycleWrapper extends LifecycleWrapper
 
             if (!facesContext.getResponseComplete() && !"default".equals(windowId))
             {
-                facesContext.getExternalContext().setClientWindow(
-                        new ClientWindowAdapter(clientWindow, delegateWindowHandling));
+                facesContext.getExternalContext().setClientWindow(new ClientWindowAdapter(clientWindow));
             }
         }
     }
@@ -144,6 +142,20 @@ public class JsfClientWindowAwareLifecycleWrapper extends LifecycleWrapper
         }
     }
 
+    @Override
+    public void render(FacesContext context) throws FacesException
+    {
+        lazyInit();
+
+        // prevent jfwid rendering
+        if (!delegateWindowHandling && context.getExternalContext().getClientWindow()
!= null)
+        {
+            context.getExternalContext().getClientWindow().disableClientWindowRenderMode(context);
+        }
+        
+        super.render(context);
+    }
+    
     private void lazyInit()
     {
         if (this.initialized == null)
@@ -155,12 +167,12 @@ public class JsfClientWindowAwareLifecycleWrapper extends LifecycleWrapper
     private synchronized void init()
     {
         // switch into paranoia mode
-        if (initialized == null)
+        if (this.initialized == null)
         {
-            delegateWindowHandling = ClientWindowConfig.ClientWindowRenderMode.DELEGATED.equals(
+            this.delegateWindowHandling = ClientWindowConfig.ClientWindowRenderMode.DELEGATED.equals(
                 BeanProvider.getContextualReference(JsfModuleConfig.class).getDefaultWindowMode());
 
-            initialized = true;
+            this.initialized = true;
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/07f0bdd7/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
index 0a61a68..4282df8 100644
--- 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
@@ -34,32 +34,10 @@ import java.util.Map;
 public class ClientWindowAdapter extends ClientWindow
 {
     private final org.apache.deltaspike.jsf.spi.scope.window.ClientWindow window;
-    private final boolean delegateWindowHandling;
 
-    public ClientWindowAdapter(org.apache.deltaspike.jsf.spi.scope.window.ClientWindow window,
-            boolean delegateWindowHandling)
+    public ClientWindowAdapter(org.apache.deltaspike.jsf.spi.scope.window.ClientWindow window)
     {
         this.window = window;
-        this.delegateWindowHandling = delegateWindowHandling;
-    }
-
-    public static Boolean isJsf22ClientWindowRenderModeEnabled(FacesContext context)
-    {
-        ClientWindow clientWindow = context.getExternalContext().getClientWindow();
-        if (clientWindow != null)
-        {
-            if (clientWindow instanceof ClientWindowAdapter)
-            {
-                ClientWindowAdapter clientWindowAdapter = (ClientWindowAdapter) clientWindow;
-                return clientWindowAdapter.isOriginalClientWindowRenderModeEnabled(context);
-            }
-            else
-            {
-                return clientWindow.isClientWindowRenderModeEnabled(context);
-            }
-        }
-        
-        return null;
     }
     
     @Override
@@ -80,20 +58,4 @@ public class ClientWindowAdapter extends ClientWindow
         //currently not needed by the window-handling of DeltaSpike
         return Collections.emptyMap();
     }
-    
-    @Override
-    public boolean isClientWindowRenderModeEnabled(FacesContext context)
-    {
-        if (!delegateWindowHandling)
-        {
-            return false;
-        }
-        
-        return super.isClientWindowRenderModeEnabled(context);
-    }
-    
-    protected boolean isOriginalClientWindowRenderModeEnabled(FacesContext context)
-    {
-        return super.isClientWindowRenderModeEnabled(context);
-    }
 }

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/07f0bdd7/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/window/strategy/AbstractClientWindowStrategy.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/window/strategy/AbstractClientWindowStrategy.java
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/window/strategy/AbstractClientWindowStrategy.java
index f3b9eca..af956a2 100644
--- a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/window/strategy/AbstractClientWindowStrategy.java
+++ b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/window/strategy/AbstractClientWindowStrategy.java
@@ -27,7 +27,6 @@ import javax.inject.Inject;
 import javax.servlet.http.HttpServletRequest;
 import org.apache.deltaspike.core.spi.scope.window.WindowContext;
 import org.apache.deltaspike.jsf.api.config.JsfModuleConfig;
-import org.apache.deltaspike.jsf.impl.scope.window.ClientWindowAdapter;
 import org.apache.deltaspike.jsf.impl.util.ClientWindowHelper;
 import org.apache.deltaspike.jsf.spi.scope.window.ClientWindow;
 import org.apache.deltaspike.jsf.spi.scope.window.ClientWindowConfig;
@@ -145,14 +144,6 @@ public abstract class AbstractClientWindowStrategy implements ClientWindow
             Map<Object, Object> attrMap = facesContext.getAttributes();
             attrMap.put(PER_USE_CLIENT_WINDOW_URL_QUERY_PARAMETER_DISABLED_KEY, Boolean.TRUE);
         }
-
-        if (jsfModuleConfig.isJsf22Available())
-        {
-            if (facesContext.getExternalContext().getClientWindow() != null)
-            {
-                facesContext.getExternalContext().getClientWindow().disableClientWindowRenderMode(facesContext);
-            }
-        }
     }
 
     @Override
@@ -163,28 +154,11 @@ public abstract class AbstractClientWindowStrategy implements ClientWindow
             Map<Object, Object> attrMap = facesContext.getAttributes();
             attrMap.remove(PER_USE_CLIENT_WINDOW_URL_QUERY_PARAMETER_DISABLED_KEY);
         }
-        
-        if (jsfModuleConfig.isJsf22Available())
-        {
-            if (facesContext.getExternalContext().getClientWindow() != null)
-            {
-                facesContext.getExternalContext().getClientWindow().enableClientWindowRenderMode(facesContext);
-            }
-        }
     }
 
     @Override
     public boolean isClientWindowRenderModeEnabled(FacesContext facesContext)
     {
-        // skip dswid rendering if JSF2.2 render mode is disabled
-        if (jsfModuleConfig.isJsf22Available())
-        {
-            if (ClientWindowAdapter.isJsf22ClientWindowRenderModeEnabled(facesContext) ==
false)
-            {
-                return false;
-            }
-        }
-
         if (isSupportClientWindowRenderingMode())
         {
             Map<Object, Object> attrMap = facesContext.getAttributes();


Mime
View raw message