This is an automated email from the ASF dual-hosted git repository.
tandraschko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/deltaspike.git
The following commit(s) were added to refs/heads/master by this push:
new 077ff6957 DELTASPIKE-1463
077ff6957 is described below
commit 077ff6957c3ba342c5ab5b447f5c244b7a0733fe
Author: Thomas Andraschko <[email protected]>
AuthorDate: Thu Mar 30 18:17:04 2023 +0200
DELTASPIKE-1463
---
.../jsf/spi/scope/window/ClientWindow.java | 84 --------
.../jsf/spi/scope/window/ClientWindowConfig.java | 8 +-
.../ClientSideClientWindow.java} | 34 ++-
.../impl/clientwindow/DeltaSpikeClientWindow.java | 142 +++++++++++++
.../LazyClientWindow.java} | 26 ++-
.../window/DisableClientWindowComponent.java | 28 ---
.../window/DisableClientWindowHtmlRenderer.java | 106 ---------
.../component/window/WindowIdHtmlRenderer.java | 20 +-
.../request/DeltaSpikeExternalContextWrapper.java | 12 +-
.../request/DeltaSpikeFacesContextFactory.java | 29 +--
.../request/DeltaSpikeFacesContextWrapper.java | 5 +-
.../request/DeltaSpikeLifecycleFactoryWrapper.java | 30 ---
.../request/DeltaSpikeLifecycleWrapper.java | 59 +++++-
.../JsfClientWindowAwareLifecycleWrapper.java | 181 ----------------
.../NavigationHandlerAwareApplication.java | 88 +-------
.../jsf/impl/scope/window/ClientWindowAdapter.java | 68 ------
.../jsf/impl/scope/window/DefaultClientWindow.java | 123 -----------
.../strategy/AbstractClientWindowStrategy.java | 236 ---------------------
.../window/strategy/DelegatedWindowStrategy.java | 39 ----
.../scope/window/strategy/NoneWindowStrategy.java | 35 ---
.../jsf/impl/util/ClientWindowHelper.java | 2 +-
.../jsf/impl/view/DeltaSpikeViewHandler.java | 14 +-
.../main/resources/META-INF/deltaspike.taglib.xml | 7 -
23 files changed, 263 insertions(+), 1113 deletions(-)
diff --git
a/deltaspike/modules/jsf/api/src/main/java/org/apache/deltaspike/jsf/spi/scope/window/ClientWindow.java
b/deltaspike/modules/jsf/api/src/main/java/org/apache/deltaspike/jsf/spi/scope/window/ClientWindow.java
deleted file mode 100644
index 1c4a5fc86..000000000
---
a/deltaspike/modules/jsf/api/src/main/java/org/apache/deltaspike/jsf/spi/scope/window/ClientWindow.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * 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.spi.scope.window;
-
-import java.util.Map;
-import jakarta.faces.context.FacesContext;
-
-/**
- * <p>API to interact with the window/browser tab handling.
- * This originally got implemented in Apache MyFaces CODI
- * which was the basis for the respective feature in JSF-2.2.
- * We now orientate us a bit on the JSF-2.2 API for making it
- * easier to provide this feature for JSF-2.0, JSF-2.1 and also
- * JSF-2.2 JSF implementations.</p>
- *
- * <p>Please not that in JSF-2.2 a
<code>jakarta.faces.lifecycle.ClientWindow</code>
- * instance gets created for each and every request, but in DeltaSpike our
- * ClientWindow instances are most likely @ApplicationScoped.
- * </p>
- */
-public interface ClientWindow
-{
- /**
- * Extract the windowId for the current request.
- * This method is intended to get executed at the start of the JSF
lifecycle.
- * We also need to take care about JSF-2.2 ClientWindow in the future.
- * Depending on the {@link ClientWindowConfig.ClientWindowRenderMode} and
- * after consulting {@link ClientWindowConfig} we will first send an
- * intermediate page if the request is an initial GET request.
- *
- * @param facesContext for the request
- * @return the extracted WindowId of the Request, or <code>null</code> if
there is no window assigned.
- */
- String getWindowId(FacesContext facesContext);
-
- /**
- * Can be called to disable the window-id for an URL.
- * Don't forget to call {@link
#enableClientWindowRenderMode(jakarta.faces.context.FacesContext)}
- * after rendering the markup for the current component, if {@link
#isClientWindowRenderModeEnabled}
- * returned <code>true</code> before calling this method.
- */
- void disableClientWindowRenderMode(FacesContext facesContext);
-
- /**
- * Can be used to reset window-id rendering for a specific component.
- */
- void enableClientWindowRenderMode(FacesContext facesContext);
-
- /**
- * @return true if the window-id should be appended during the
rendering-process, false otherwise
- */
- boolean isClientWindowRenderModeEnabled(FacesContext facesContext);
-
- /**
- * @return meta-data for the current window which should get added to
URLs, null otherwise
- */
- Map<String, String> getQueryURLParameters(FacesContext facesContext);
-
- /**
- * @return true if the implementation possible sends an initial redirect.
- */
- boolean isInitialRedirectSupported(FacesContext facesContext);
-
- /**
- * @return The new redirect url.
- */
- String interceptRedirect(FacesContext facesContext, String url);
-}
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 cc258c94e..c63dcd102 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
@@ -50,15 +50,9 @@ public interface ClientWindowConfig extends Serializable
LAZY,
/**
- * Delegates to the default window-handling of JSF 2.2+ (if configured)
+ * Delegates to the default window-handling
*/
DELEGATED,
-
- /**
- * If you set this mode, you also need to provide an own {@link
ClientWindow} implementation.
- */
- CUSTOM
-
}
/**
diff --git
a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/window/strategy/ClientSideWindowStrategy.java
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/clientwindow/ClientSideClientWindow.java
similarity index 92%
rename from
deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/window/strategy/ClientSideWindowStrategy.java
rename to
deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/clientwindow/ClientSideClientWindow.java
index c2750775d..9cd77c27a 100644
---
a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/window/strategy/ClientSideWindowStrategy.java
+++
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/clientwindow/ClientSideClientWindow.java
@@ -16,23 +16,20 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.deltaspike.jsf.impl.scope.window.strategy;
+package org.apache.deltaspike.jsf.impl.clientwindow;
import java.io.IOException;
import java.io.OutputStream;
-import jakarta.enterprise.context.Dependent;
-import jakarta.enterprise.inject.Typed;
import jakarta.faces.FacesException;
import jakarta.faces.context.ExternalContext;
import jakarta.faces.context.FacesContext;
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletResponse;
+import java.util.Map;
import org.apache.deltaspike.jsf.impl.util.ClientWindowHelper;
import org.apache.deltaspike.jsf.impl.util.JsfUtils;
-@Dependent
-@Typed(ClientSideWindowStrategy.class)
-public class ClientSideWindowStrategy extends AbstractClientWindowStrategy
+public class ClientSideClientWindow extends DeltaSpikeClientWindow
{
/**
* Value which can be used as "window-id" by external clients which aren't
aware of windows.
@@ -66,7 +63,7 @@ public class ClientSideWindowStrategy extends
AbstractClientWindowStrategy
else if (isNoscriptRequest(facesContext.getExternalContext()))
{
// the client has JavaScript disabled
- clientWindowConfig.setJavaScriptEnabled(false);
+ getClientWindowConfig().setJavaScriptEnabled(false);
windowId = DEFAULT_WINDOW_ID;
}
@@ -109,8 +106,7 @@ public class ClientSideWindowStrategy extends
AbstractClientWindowStrategy
httpResponse.setStatus(HttpServletResponse.SC_OK);
httpResponse.setContentType("text/html");
- String windowHandlerHtml =
clientWindowConfig.getClientWindowHtml();
-
+ String windowHandlerHtml =
getClientWindowConfig().getClientWindowHtml();
if (windowId == null)
{
windowId = UNINITIALIZED_WINDOW_ID_VALUE;
@@ -231,7 +227,7 @@ public class ClientSideWindowStrategy extends
AbstractClientWindowStrategy
if ((!ajax && get) || (ajax && post))
{
String requestToken = generateNewRequestToken();
- String windowId = getWindowId(facesContext);
+ String windowId = getId();
ClientWindowHelper.addRequestWindowIdCookie(facesContext,
requestToken,
@@ -253,4 +249,22 @@ public class ClientSideWindowStrategy extends
AbstractClientWindowStrategy
return url;
}
+
+ @Override
+ public boolean isInitialRedirectSupported(FacesContext facesContext)
+ {
+ return false;
+ }
+
+ @Override
+ public Map<String, String> getQueryURLParameters(FacesContext facesContext)
+ {
+ return null;
+ }
+
+ @Override
+ public boolean isClientWindowRenderModeEnabled(FacesContext facesContext)
+ {
+ return false;
+ }
}
diff --git
a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/clientwindow/DeltaSpikeClientWindow.java
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/clientwindow/DeltaSpikeClientWindow.java
new file mode 100644
index 000000000..586acd95c
--- /dev/null
+++
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/clientwindow/DeltaSpikeClientWindow.java
@@ -0,0 +1,142 @@
+/*
+ * 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.clientwindow;
+
+import jakarta.faces.context.FacesContext;
+import jakarta.faces.lifecycle.ClientWindow;
+import jakarta.servlet.http.HttpServletRequest;
+import java.util.Map;
+import java.util.Random;
+import org.apache.deltaspike.core.api.provider.BeanProvider;
+import org.apache.deltaspike.core.util.StringUtils;
+import org.apache.deltaspike.jsf.impl.util.ClientWindowHelper;
+import org.apache.deltaspike.jsf.spi.scope.window.ClientWindowConfig;
+
+public abstract class DeltaSpikeClientWindow extends ClientWindow
+{
+ /**
+ * This windowId will be used for all requests with disabled windowId
feature
+ */
+ public static final String DEFAULT_WINDOW_ID = "default";
+
+ private String id;
+ private int maxWindowIdCount = 10;
+
+ public DeltaSpikeClientWindow()
+ {
+ this.maxWindowIdCount = ClientWindowHelper.getMaxWindowIdLength();
+ }
+
+ @Override
+ public void decode(FacesContext facesContext)
+ {
+ id = getOrCreateWindowId(facesContext);
+
+ if (id != null)
+ {
+ id = sanitiseWindowId(id);
+ if (id.length() > this.maxWindowIdCount)
+ {
+ id = id.substring(0, this.maxWindowIdCount);
+ }
+ }
+ }
+
+ @Override
+ public String getId()
+ {
+ return id;
+ }
+
+ /**
+ * We have to escape some characters to make sure we do not open
+ * any XSS vectors. E.g. replace (,<, & etc to
+ * prevent attackers from injecting JavaScript function calls or html.
+ */
+ protected String sanitiseWindowId(String windowId)
+ {
+ return StringUtils.removeSpecialChars(windowId);
+ }
+
+ protected String generateNewWindowId()
+ {
+ //X TODO proper mechanism
+ return Integer.toString((new Random()).nextInt() % 10000);
+ }
+
+ protected String generateNewRequestToken()
+ {
+ return Integer.toString((int) Math.floor(Math.random() * 999));
+ }
+
+ protected boolean isPost(FacesContext facesContext)
+ {
+ if (facesContext.isPostback())
+ {
+ return true;
+ }
+
+ Object request = facesContext.getExternalContext().getRequest();
+ if (request instanceof HttpServletRequest)
+ {
+ if ("POST".equals(((HttpServletRequest) request).getMethod()))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ protected String getWindowIdPostParameter(FacesContext facesContext)
+ {
+ Map<String, String> requestParams =
facesContext.getExternalContext().getRequestParameterMap();
+ String windowId =
requestParams.get(ClientWindowHelper.RequestParameters.POST_WINDOW_ID);
+
+ if (windowId == null)
+ {
+ windowId =
requestParams.get(ClientWindowHelper.RequestParameters.JSF_POST_WINDOW_ID);
+ }
+
+ return windowId;
+ }
+
+ protected String getWindowIdParameter(FacesContext facesContext)
+ {
+ Map<String, String> requestParameters =
facesContext.getExternalContext().getRequestParameterMap();
+ return
requestParameters.get(ClientWindowHelper.RequestParameters.GET_WINDOW_ID);
+ }
+
+ protected ClientWindowConfig getClientWindowConfig()
+ {
+ return BeanProvider.getContextualReference(ClientWindowConfig.class);
+ }
+
+ protected abstract String getOrCreateWindowId(FacesContext facesContext);
+
+ /**
+ * @return true if the implementation possible sends an initial redirect.
+ */
+ public abstract boolean isInitialRedirectSupported(FacesContext
facesContext);
+
+ /**
+ * @return The new redirect url.
+ */
+ public abstract String interceptRedirect(FacesContext facesContext, String
url);
+}
diff --git
a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/window/strategy/LazyWindowStrategy.java
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/clientwindow/LazyClientWindow.java
similarity index 79%
rename from
deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/window/strategy/LazyWindowStrategy.java
rename to
deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/clientwindow/LazyClientWindow.java
index 092699f46..7d333f065 100644
---
a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/window/strategy/LazyWindowStrategy.java
+++
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/clientwindow/LazyClientWindow.java
@@ -16,20 +16,18 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.deltaspike.jsf.impl.scope.window.strategy;
+package org.apache.deltaspike.jsf.impl.clientwindow;
import org.apache.deltaspike.jsf.impl.util.ClientWindowHelper;
import jakarta.faces.context.FacesContext;
import java.util.HashMap;
import java.util.Map;
-import jakarta.enterprise.context.Dependent;
-import jakarta.enterprise.inject.Typed;
+import org.apache.deltaspike.core.api.provider.BeanProvider;
import org.apache.deltaspike.core.util.StringUtils;
+import org.apache.deltaspike.jsf.api.config.JsfModuleConfig;
-@Dependent
-@Typed(LazyWindowStrategy.class)
-public class LazyWindowStrategy extends AbstractClientWindowStrategy
+public class LazyClientWindow extends DeltaSpikeClientWindow
{
@Override
protected String getOrCreateWindowId(FacesContext facesContext)
@@ -50,6 +48,7 @@ public class LazyWindowStrategy extends
AbstractClientWindowStrategy
if (StringUtils.isEmpty(windowId))
{
+ JsfModuleConfig jsfModuleConfig =
BeanProvider.getContextualReference(JsfModuleConfig.class);
if (jsfModuleConfig.isInitialRedirectEnabled() && !post)
{
ClientWindowHelper.handleInitialRedirect(facesContext,
generateNewWindowId());
@@ -66,29 +65,28 @@ public class LazyWindowStrategy extends
AbstractClientWindowStrategy
}
@Override
- protected Map<String, String> createQueryURLParameters(FacesContext
facesContext)
+ public Map<String, String> getQueryURLParameters(FacesContext facesContext)
{
- String windowId = getWindowId(facesContext);
-
+ String windowId = getId();
if (windowId == null)
{
return null;
}
- Map<String, String> parameters = new HashMap<String, String>();
+ Map<String, String> parameters = new HashMap<>();
parameters.put(ClientWindowHelper.RequestParameters.GET_WINDOW_ID,
windowId);
return parameters;
}
-
+
@Override
- protected boolean isSupportClientWindowRenderingMode()
+ public boolean isInitialRedirectSupported(FacesContext facesContext)
{
return true;
}
@Override
- public boolean isInitialRedirectSupported(FacesContext facesContext)
+ public String interceptRedirect(FacesContext facesContext, String url)
{
- return true;
+ return url;
}
}
diff --git
a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/component/window/DisableClientWindowComponent.java
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/component/window/DisableClientWindowComponent.java
deleted file mode 100644
index cdefd0122..000000000
---
a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/component/window/DisableClientWindowComponent.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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.component.window;
-
-import jakarta.faces.component.FacesComponent;
-import jakarta.faces.component.UIOutput;
-
-@FacesComponent(DisableClientWindowComponent.COMPONENT_TYPE)
-public class DisableClientWindowComponent extends UIOutput
-{
- public static final String COMPONENT_TYPE =
"org.apache.deltaspike.DisableClientWindow";
-}
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
deleted file mode 100644
index 7952cc40b..000000000
---
a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/component/window/DisableClientWindowHtmlRenderer.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * 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.component.window;
-
-import java.io.IOException;
-import jakarta.faces.component.UIComponent;
-import jakarta.faces.context.FacesContext;
-import jakarta.faces.render.FacesRenderer;
-import jakarta.faces.render.Renderer;
-import org.apache.deltaspike.core.api.provider.BeanProvider;
-import org.apache.deltaspike.jsf.api.config.JsfModuleConfig;
-import org.apache.deltaspike.jsf.spi.scope.window.ClientWindow;
-
-@FacesRenderer(componentFamily = DisableClientWindowComponent.COMPONENT_FAMILY,
- rendererType = DisableClientWindowComponent.COMPONENT_TYPE)
-public class DisableClientWindowHtmlRenderer extends Renderer
-{
- private volatile Boolean initialized;
-
- private ClientWindow clientWindow;
- private JsfModuleConfig jsfModuleConfig;
-
- @Override
- public void encodeChildren(FacesContext context, UIComponent component)
throws IOException
- {
- lazyInit();
-
- boolean dsClientWindowRenderModeEnabled =
clientWindow.isClientWindowRenderModeEnabled(context);
- boolean jsfClientWindowRenderModeEnabled = false;
-
- if (jsfModuleConfig.isJsf22Available())
- {
- if (context.getExternalContext().getClientWindow() != null)
- {
- jsfClientWindowRenderModeEnabled =
-
context.getExternalContext().getClientWindow().isClientWindowRenderModeEnabled(context);
- }
- }
-
- try
- {
- if (dsClientWindowRenderModeEnabled)
- {
- clientWindow.disableClientWindowRenderMode(context);
- }
- if (jsfClientWindowRenderModeEnabled)
- {
-
context.getExternalContext().getClientWindow().disableClientWindowRenderMode(context);
- }
-
- super.encodeChildren(context, component);
- }
- finally
- {
- if (dsClientWindowRenderModeEnabled)
- {
- clientWindow.enableClientWindowRenderMode(context);
- }
- if (jsfClientWindowRenderModeEnabled)
- {
-
context.getExternalContext().getClientWindow().enableClientWindowRenderMode(context);
- }
- }
- }
-
- @Override
- public boolean getRendersChildren()
- {
- return true;
- }
-
- private void lazyInit()
- {
- if (this.initialized == null)
- {
- init();
- }
- }
-
- protected synchronized void init()
- {
- if (this.initialized == null)
- {
- clientWindow =
BeanProvider.getContextualReference(ClientWindow.class);
- jsfModuleConfig =
BeanProvider.getContextualReference(JsfModuleConfig.class);
-
- this.initialized = true;
- }
- }
-}
diff --git
a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/component/window/WindowIdHtmlRenderer.java
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/component/window/WindowIdHtmlRenderer.java
index b8d8e594f..70bc6f581 100644
---
a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/component/window/WindowIdHtmlRenderer.java
+++
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/component/window/WindowIdHtmlRenderer.java
@@ -23,6 +23,7 @@ import jakarta.faces.application.ResourceDependency;
import jakarta.faces.component.UIComponent;
import jakarta.faces.context.FacesContext;
import jakarta.faces.context.ResponseWriter;
+import jakarta.faces.lifecycle.ClientWindow;
import jakarta.faces.render.FacesRenderer;
import jakarta.faces.render.Renderer;
import java.io.IOException;
@@ -30,8 +31,8 @@ import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletResponse;
import org.apache.deltaspike.core.api.provider.BeanProvider;
+import org.apache.deltaspike.jsf.impl.clientwindow.DeltaSpikeClientWindow;
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;
@FacesRenderer(componentFamily = WindowIdComponent.COMPONENT_FAMILY,
rendererType = WindowIdComponent.COMPONENT_TYPE)
@@ -40,7 +41,6 @@ import
org.apache.deltaspike.jsf.spi.scope.window.ClientWindowConfig;
@ResourceDependency(library = "jakarta.faces", name = "jsf.js", target
= "head") } )
public class WindowIdHtmlRenderer extends Renderer
{
- private volatile ClientWindow clientWindow;
private volatile ClientWindowConfig clientWindowConfig;
private int maxWindowIdLength = 10;
@@ -70,7 +70,13 @@ public class WindowIdHtmlRenderer extends Renderer
return;
}
- String windowId = clientWindow.getWindowId(context);
+ ClientWindow clientWindow =
context.getExternalContext().getClientWindow();
+ if (clientWindow == null && !(clientWindow instanceof
DeltaSpikeClientWindow))
+ {
+ return;
+ }
+
+ String windowId = clientWindow.getId();
// just to get sure if a user provides a own client window
windowId = secureWindowId(windowId);
@@ -90,7 +96,7 @@ public class WindowIdHtmlRenderer extends Renderer
+
clientWindowConfig.isClientWindowStoreWindowTreeEnabledOnButtonClick());
// see #729
- if (clientWindow.isInitialRedirectSupported(context))
+ if (((DeltaSpikeClientWindow)
clientWindow).isInitialRedirectSupported(context))
{
Object cookie =
ClientWindowHelper.getRequestWindowIdCookie(context, windowId);
if (cookie != null && cookie instanceof Cookie)
@@ -120,16 +126,14 @@ public class WindowIdHtmlRenderer extends Renderer
private void lazyInit()
{
- if (clientWindow == null)
+ if (clientWindowConfig == null)
{
synchronized (this)
{
- if (clientWindow == null)
+ if (clientWindowConfig == null)
{
clientWindowConfig =
BeanProvider.getContextualReference(ClientWindowConfig.class);
maxWindowIdLength =
ClientWindowHelper.getMaxWindowIdLength();
-
- clientWindow =
BeanProvider.getContextualReference(ClientWindow.class);
}
}
}
diff --git
a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/DeltaSpikeExternalContextWrapper.java
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/DeltaSpikeExternalContextWrapper.java
index 3ba5f464b..ab7c7e78c 100644
---
a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/DeltaSpikeExternalContextWrapper.java
+++
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/DeltaSpikeExternalContextWrapper.java
@@ -25,18 +25,17 @@ import jakarta.faces.context.ExternalContext;
import jakarta.faces.context.ExternalContextWrapper;
import java.io.IOException;
import jakarta.faces.context.FacesContext;
+import jakarta.faces.lifecycle.ClientWindow;
+import org.apache.deltaspike.jsf.impl.clientwindow.DeltaSpikeClientWindow;
import org.apache.deltaspike.jsf.impl.util.ClientWindowHelper;
-import org.apache.deltaspike.jsf.spi.scope.window.ClientWindow;
public class DeltaSpikeExternalContextWrapper extends ExternalContextWrapper
implements Deactivatable
{
private final ExternalContext wrapped;
- private final ClientWindow clientWindow;
- DeltaSpikeExternalContextWrapper(ExternalContext wrapped, ClientWindow
clientWindow)
+ DeltaSpikeExternalContextWrapper(ExternalContext wrapped)
{
this.wrapped = wrapped;
- this.clientWindow = clientWindow;
}
@Override
@@ -51,9 +50,10 @@ public class DeltaSpikeExternalContextWrapper extends
ExternalContextWrapper imp
JsfUtils.saveFacesMessages(this.wrapped);
}
- if (clientWindow != null)
+ ClientWindow clientWindow = getClientWindow();
+ if (clientWindow != null && clientWindow instanceof
DeltaSpikeClientWindow)
{
- url = clientWindow.interceptRedirect(facesContext, url);
+ url = ((DeltaSpikeClientWindow)
clientWindow).interceptRedirect(facesContext, url);
}
this.wrapped.redirect(url);
diff --git
a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/DeltaSpikeFacesContextFactory.java
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/DeltaSpikeFacesContextFactory.java
index 4353132b3..b0e97cd1d 100644
---
a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/DeltaSpikeFacesContextFactory.java
+++
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/DeltaSpikeFacesContextFactory.java
@@ -24,18 +24,12 @@ import
org.apache.deltaspike.core.util.ClassDeactivationUtils;
import jakarta.faces.context.FacesContext;
import jakarta.faces.context.FacesContextFactory;
import jakarta.faces.lifecycle.Lifecycle;
-import org.apache.deltaspike.core.api.provider.BeanProvider;
-import org.apache.deltaspike.jsf.spi.scope.window.ClientWindow;
public class DeltaSpikeFacesContextFactory extends FacesContextFactory
implements Deactivatable
{
private final FacesContextFactory wrappedFacesContextFactory;
private final boolean deactivated;
-
- private volatile Boolean initialized;
-
- private ClientWindow clientWindow;
/**
* Constructor for wrapping the given {@link FacesContextFactory}
@@ -66,10 +60,8 @@ public class DeltaSpikeFacesContextFactory extends
FacesContextFactory implement
{
return facesContext;
}
-
- lazyInit();
- return new DeltaSpikeFacesContextWrapper(facesContext, clientWindow);
+ return new DeltaSpikeFacesContextWrapper(facesContext);
}
/**
@@ -80,23 +72,4 @@ public class DeltaSpikeFacesContextFactory extends
FacesContextFactory implement
{
return wrappedFacesContextFactory;
}
-
- private void lazyInit()
- {
- if (this.initialized == null)
- {
- init();
- }
- }
-
- private synchronized void init()
- {
- // switch into paranoia mode
- if (this.initialized == null)
- {
- this.clientWindow =
BeanProvider.getContextualReference(ClientWindow.class, true);
-
- this.initialized = true;
- }
- }
}
\ No newline at end of file
diff --git
a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/DeltaSpikeFacesContextWrapper.java
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/DeltaSpikeFacesContextWrapper.java
index 09e86ff0f..69f4b4382 100644
---
a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/DeltaSpikeFacesContextWrapper.java
+++
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/DeltaSpikeFacesContextWrapper.java
@@ -46,7 +46,6 @@ import
org.apache.deltaspike.jsf.impl.exception.control.BridgeExceptionHandlerWr
import
org.apache.deltaspike.jsf.impl.navigation.NavigationHandlerAwareApplication;
import org.apache.deltaspike.jsf.impl.security.SecurityAwareViewHandler;
-import org.apache.deltaspike.jsf.spi.scope.window.ClientWindow;
class DeltaSpikeFacesContextWrapper extends FacesContextWrapper
{
@@ -71,14 +70,14 @@ class DeltaSpikeFacesContextWrapper extends
FacesContextWrapper
private boolean preDestroyViewMapEventFilterMode;
private ProjectStage projectStage;
- DeltaSpikeFacesContextWrapper(FacesContext wrappedFacesContext,
ClientWindow clientWindow)
+ DeltaSpikeFacesContextWrapper(FacesContext wrappedFacesContext)
{
this.wrappedFacesContext = wrappedFacesContext;
if
(ClassDeactivationUtils.isActivated(DeltaSpikeExternalContextWrapper.class))
{
this.wrappedExternalContext =
- new
DeltaSpikeExternalContextWrapper(wrappedFacesContext.getExternalContext(),
clientWindow);
+ new
DeltaSpikeExternalContextWrapper(wrappedFacesContext.getExternalContext());
}
else
{
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 bd6853d78..80d65371b 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,10 +21,6 @@ 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 org.apache.deltaspike.jsf.impl.util.JsfUtils;
import jakarta.faces.lifecycle.Lifecycle;
import jakarta.faces.lifecycle.LifecycleFactory;
@@ -36,8 +32,6 @@ public class DeltaSpikeLifecycleFactoryWrapper extends
LifecycleFactory implemen
private final boolean deactivated;
- private final boolean jsfVersionWithClientWindowDetected;
-
/**
* Constructor for wrapping the given {@link LifecycleFactory}
*
@@ -47,16 +41,6 @@ public class DeltaSpikeLifecycleFactoryWrapper extends
LifecycleFactory implemen
{
this.wrapped = wrapped;
this.deactivated = !ClassDeactivationUtils.isActivated(getClass());
- boolean jsfVersionWithClientWindowDetected =
-
ClassUtils.tryToLoadClassForName(JsfModuleConfig.CLIENT_WINDOW_CLASS_NAME) !=
null;
-
- if (jsfVersionWithClientWindowDetected &&
ClassUtils.tryToLoadClassForName(
-
"org.apache.deltaspike.jsf.impl.listener.request.JsfClientWindowAwareLifecycleWrapper")
== null)
- {
- jsfVersionWithClientWindowDetected = false;
- JsfUtils.logWrongModuleUsage(getClass().getName());
- }
- this.jsfVersionWithClientWindowDetected =
jsfVersionWithClientWindowDetected;
}
@Override
@@ -75,20 +59,6 @@ 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 (Lifecycle) lifecycleWrapperClass.getConstructor(new
Class[] { Lifecycle.class })
- .newInstance(new DeltaSpikeLifecycleWrapper(result));
- }
- catch (Exception e)
- {
- throw ExceptionUtils.throwAsRuntimeException(e);
- }
- }
return new DeltaSpikeLifecycleWrapper(result);
}
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 eed193c3c..e644df3b8 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
@@ -21,21 +21,24 @@ package org.apache.deltaspike.jsf.impl.listener.request;
import org.apache.deltaspike.core.api.provider.BeanProvider;
import org.apache.deltaspike.core.spi.scope.window.WindowContext;
import org.apache.deltaspike.core.util.ClassDeactivationUtils;
-import org.apache.deltaspike.jsf.spi.scope.window.ClientWindow;
import jakarta.faces.context.FacesContext;
import jakarta.faces.event.PhaseListener;
+import jakarta.faces.lifecycle.ClientWindow;
import jakarta.faces.lifecycle.Lifecycle;
import org.apache.deltaspike.core.impl.scope.DeltaSpikeContextExtension;
import org.apache.deltaspike.core.impl.scope.viewaccess.ViewAccessContext;
+import org.apache.deltaspike.jsf.impl.clientwindow.ClientSideClientWindow;
+import org.apache.deltaspike.jsf.impl.clientwindow.LazyClientWindow;
+import org.apache.deltaspike.jsf.spi.scope.window.ClientWindowConfig;
class DeltaSpikeLifecycleWrapper extends Lifecycle
{
private final Lifecycle wrapped;
private JsfRequestBroadcaster jsfRequestBroadcaster;
+ private ClientWindowConfig clientWindowConfig;
- private ClientWindow clientWindow;
private WindowContext windowContext;
private DeltaSpikeContextExtension contextExtension;
@@ -78,10 +81,14 @@ class DeltaSpikeLifecycleWrapper extends Lifecycle
broadcastInitializedJsfRequestEvent(facesContext);
// ClientWindow handling
- String windowId = clientWindow.getWindowId(facesContext);
- if (windowId != null)
+ ClientWindow clientWindow =
facesContext.getExternalContext().getClientWindow();
+ if (clientWindow != null)
{
- windowContext.activateWindow(windowId);
+ String windowId = clientWindow.getId();
+ if (windowId != null)
+ {
+ windowContext.activateWindow(windowId);
+ }
}
if (!FacesContext.getCurrentInstance().getResponseComplete())
@@ -108,6 +115,14 @@ class DeltaSpikeLifecycleWrapper extends Lifecycle
@Override
public void render(FacesContext facesContext)
{
+ // prevent jfwid rendering
+ boolean delegateWindowHandling =
ClientWindowConfig.ClientWindowRenderMode.DELEGATED.equals(
+ clientWindowConfig.getClientWindowRenderMode(facesContext));
+ if (!delegateWindowHandling &&
facesContext.getExternalContext().getClientWindow() != null)
+ {
+
facesContext.getExternalContext().getClientWindow().disableClientWindowRenderMode(facesContext);
+ }
+
this.wrapped.render(facesContext);
if (facesContext.getViewRoot() != null &&
facesContext.getViewRoot().getViewId() != null)
@@ -120,6 +135,34 @@ class DeltaSpikeLifecycleWrapper extends Lifecycle
}
}
+ @Override
+ public void attachWindow(FacesContext facesContext)
+ {
+ lazyInit();
+
+ ClientWindowConfig.ClientWindowRenderMode clientWindowRenderMode =
+ clientWindowConfig.getClientWindowRenderMode(facesContext);
+
+ if (clientWindowRenderMode ==
ClientWindowConfig.ClientWindowRenderMode.DELEGATED)
+ {
+ this.wrapped.attachWindow(facesContext);
+ }
+ else
+ {
+ if (!facesContext.getResponseComplete())
+ {
+ if (clientWindowRenderMode ==
ClientWindowConfig.ClientWindowRenderMode.LAZY)
+ {
+ facesContext.getExternalContext().setClientWindow(new
LazyClientWindow());
+ }
+ else
+ {
+ facesContext.getExternalContext().setClientWindow(new
ClientSideClientWindow());
+ }
+ }
+ }
+ }
+
private void broadcastInitializedJsfRequestEvent(FacesContext facesContext)
{
if (this.jsfRequestBroadcaster != null)
@@ -147,9 +190,9 @@ class DeltaSpikeLifecycleWrapper extends Lifecycle
BeanProvider.getContextualReference(JsfRequestBroadcaster.class, true);
}
- clientWindow =
BeanProvider.getContextualReference(ClientWindow.class, true);
- windowContext =
BeanProvider.getContextualReference(WindowContext.class, true);
- contextExtension =
BeanProvider.getContextualReference(DeltaSpikeContextExtension.class, true);
+ this.windowContext =
BeanProvider.getContextualReference(WindowContext.class, true);
+ this.contextExtension =
BeanProvider.getContextualReference(DeltaSpikeContextExtension.class, true);
+ this.clientWindowConfig =
BeanProvider.getContextualReference(ClientWindowConfig.class);
this.initialized = true;
}
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
deleted file mode 100644
index 2f27bc579..000000000
---
a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/JsfClientWindowAwareLifecycleWrapper.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * 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.ExceptionUtils;
-import org.apache.deltaspike.jsf.impl.scope.window.ClientWindowAdapter;
-import org.apache.deltaspike.jsf.spi.scope.window.ClientWindow;
-import org.apache.deltaspike.jsf.spi.scope.window.ClientWindowConfig;
-
-import jakarta.faces.context.FacesContext;
-import jakarta.faces.lifecycle.Lifecycle;
-import jakarta.faces.lifecycle.LifecycleWrapper;
-import java.lang.reflect.Field;
-import jakarta.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)
-
-@SuppressWarnings("UnusedDeclaration")
-public class JsfClientWindowAwareLifecycleWrapper extends LifecycleWrapper
-{
- private final Lifecycle wrapped;
-
- private volatile Boolean initialized;
- private ClientWindowConfig clientWindowConfig;
-
- public JsfClientWindowAwareLifecycleWrapper(Lifecycle wrapped)
- {
- this.wrapped = wrapped;
- }
-
- @Override
- public Lifecycle getWrapped()
- {
- return wrapped;
- }
-
- @Override
- public void attachWindow(FacesContext facesContext)
- {
- lazyInit();
-
- boolean delegateWindowHandling =
ClientWindowConfig.ClientWindowRenderMode.DELEGATED.equals(
- clientWindowConfig.getClientWindowRenderMode(facesContext));
-
- if (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 jakarta.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);
- }
- }
-
- @Override
- public void render(FacesContext facesContext) throws FacesException
- {
- lazyInit();
-
- // prevent jfwid rendering
- boolean delegateWindowHandling =
ClientWindowConfig.ClientWindowRenderMode.DELEGATED.equals(
- clientWindowConfig.getClientWindowRenderMode(facesContext));
- if (!delegateWindowHandling &&
facesContext.getExternalContext().getClientWindow() != null)
- {
-
facesContext.getExternalContext().getClientWindow().disableClientWindowRenderMode(facesContext);
- }
-
- super.render(facesContext);
- }
-
- private void lazyInit()
- {
- if (this.initialized == null)
- {
- init();
- }
- }
-
- private synchronized void init()
- {
- // switch into paranoia mode
- if (this.initialized == null)
- {
- this.clientWindowConfig =
BeanProvider.getContextualReference(ClientWindowConfig.class);
-
- this.initialized = true;
- }
- }
-}
diff --git
a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/navigation/NavigationHandlerAwareApplication.java
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/navigation/NavigationHandlerAwareApplication.java
index 9be5c3b5e..ae79c3f60 100644
---
a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/navigation/NavigationHandlerAwareApplication.java
+++
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/navigation/NavigationHandlerAwareApplication.java
@@ -19,20 +19,14 @@
package org.apache.deltaspike.jsf.impl.navigation;
import org.apache.deltaspike.core.spi.activation.Deactivatable;
-import org.apache.deltaspike.core.util.ClassUtils;
-import org.apache.deltaspike.core.util.ExceptionUtils;
-import org.apache.deltaspike.jsf.impl.util.JsfUtils;
import jakarta.faces.application.Application;
import jakarta.faces.application.ApplicationWrapper;
-import jakarta.faces.application.ConfigurableNavigationHandler;
+import jakarta.faces.application.ConfigurableNavigationHandlerWrapper;
import jakarta.faces.application.NavigationHandler;
-import java.lang.reflect.Constructor;
public class NavigationHandlerAwareApplication extends ApplicationWrapper
implements Deactivatable
{
- private static volatile Boolean manualNavigationHandlerWrapperMode;
- private static Class navigationHandlerWrapperClass;
private final Application wrapped;
public NavigationHandlerAwareApplication(Application wrapped)
@@ -43,84 +37,8 @@ public class NavigationHandlerAwareApplication extends
ApplicationWrapper implem
@Override
public NavigationHandler getNavigationHandler()
{
- return wrapNavigationHandler(this.wrapped.getNavigationHandler());
- }
-
- private NavigationHandler wrapNavigationHandler(NavigationHandler handler)
- {
- NavigationHandler result = null;
-
- if (manualNavigationHandlerWrapperMode == null)
- {
- lazyInit();
- }
-
- //jsf 2.2+
- if (!manualNavigationHandlerWrapperMode)
- {
- result = wrapNavigationHandlerWithNewWrapper(handler);
- }
- if (result != null)
- {
- return result;
- }
-
- //jsf 2.0 and 2.1
- return new DeltaSpikeNavigationHandler(handler);
- }
-
- private static synchronized void lazyInit()
- {
- if (manualNavigationHandlerWrapperMode != null)
- {
- return;
- }
-
- Class wrapperClass = ClassUtils
-
.tryToLoadClassForName("jakarta.faces.application.ConfigurableNavigationHandlerWrapper");
-
- if (wrapperClass != null)
- {
- navigationHandlerWrapperClass =
- ClassUtils.tryToLoadClassForName(
-
"org.apache.deltaspike.jsf.impl.navigation.DeltaSpikeNavigationHandlerWrapper");
-
- if (navigationHandlerWrapperClass != null)
- {
- manualNavigationHandlerWrapperMode = false;
- }
- else
- {
-
JsfUtils.logWrongModuleUsage(NavigationHandlerAwareApplication.class.getName());
- manualNavigationHandlerWrapperMode = true;
- }
- }
- else
- {
- manualNavigationHandlerWrapperMode = true;
- }
- }
-
- private NavigationHandler
wrapNavigationHandlerWithNewWrapper(NavigationHandler handler)
- {
- if
(ConfigurableNavigationHandler.class.isAssignableFrom(handler.getClass()))
- {
- try
- {
- Constructor deltaSpikeNavigationHandlerWrapperConstructor =
-
navigationHandlerWrapperClass.getConstructor(ConfigurableNavigationHandler.class);
-
- NavigationHandler navigationHandlerWrapper =
-
(NavigationHandler)deltaSpikeNavigationHandlerWrapperConstructor.newInstance(handler);
- return navigationHandlerWrapper;
- }
- catch (Exception e)
- {
- throw ExceptionUtils.throwAsRuntimeException(e);
- }
- }
-
- return null;
+ NavigationHandler wrappedNavigationHandler =
this.wrapped.getNavigationHandler();
+ return new
DeltaSpikeNavigationHandlerWrapper((ConfigurableNavigationHandlerWrapper)
wrappedNavigationHandler);
}
@Override
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
deleted file mode 100644
index b6f7daa6c..000000000
---
a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/window/ClientWindowAdapter.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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 jakarta.faces.context.FacesContext;
-import jakarta.faces.lifecycle.ClientWindow;
-import java.util.Collections;
-import java.util.Map;
-
-//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)
-
-/**
- * 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;
- }
-
- @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();
- }
-
- @Override
- public boolean isClientWindowRenderModeEnabled(FacesContext context)
- {
- return false;
- }
-
-}
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
deleted file mode 100644
index 6e9308eb7..000000000
---
a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/window/DefaultClientWindow.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * 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 org.apache.deltaspike.jsf.spi.scope.window.ClientWindow;
-import org.apache.deltaspike.jsf.spi.scope.window.ClientWindowConfig;
-
-import jakarta.enterprise.context.ApplicationScoped;
-import jakarta.faces.context.FacesContext;
-import jakarta.inject.Inject;
-import java.util.Map;
-import
org.apache.deltaspike.jsf.impl.scope.window.strategy.ClientSideWindowStrategy;
-import
org.apache.deltaspike.jsf.impl.scope.window.strategy.DelegatedWindowStrategy;
-import org.apache.deltaspike.jsf.impl.scope.window.strategy.LazyWindowStrategy;
-import org.apache.deltaspike.jsf.impl.scope.window.strategy.NoneWindowStrategy;
-
-import static
org.apache.deltaspike.jsf.spi.scope.window.ClientWindowConfig.ClientWindowRenderMode;
-
-/**
- * This is the default implementation of the window/browser tab
- * detection handling for JSF applications.
- * This is to big degrees a port of Apache MyFaces CODI
- * ClientSideWindowHandler.
- *
- * It will act according to the configured {@link ClientWindowRenderMode}.
- */
-@ApplicationScoped
-public class DefaultClientWindow implements ClientWindow
-{
- @Inject
- private ClientWindowConfig clientWindowConfig;
-
- @Inject
- private ClientSideWindowStrategy clientSideWindowStrategy;
-
- @Inject
- private DelegatedWindowStrategy delegatedWindowStrategy;
-
- @Inject
- private LazyWindowStrategy lazyWindowStrategy;
-
- @Inject
- private NoneWindowStrategy noneWindowStrategy;
-
- @Override
- public String getWindowId(FacesContext facesContext)
- {
- return getClientWindow(facesContext).getWindowId(facesContext);
- }
-
- @Override
- public void disableClientWindowRenderMode(FacesContext facesContext)
- {
-
getClientWindow(facesContext).disableClientWindowRenderMode(facesContext);
- }
-
- @Override
- public void enableClientWindowRenderMode(FacesContext facesContext)
- {
-
getClientWindow(facesContext).enableClientWindowRenderMode(facesContext);
- }
-
- @Override
- public boolean isClientWindowRenderModeEnabled(FacesContext facesContext)
- {
- return
getClientWindow(facesContext).isClientWindowRenderModeEnabled(facesContext);
- }
-
- @Override
- public Map<String, String> getQueryURLParameters(FacesContext facesContext)
- {
- return
getClientWindow(facesContext).getQueryURLParameters(facesContext);
- }
-
- @Override
- public boolean isInitialRedirectSupported(FacesContext facesContext)
- {
- return
getClientWindow(facesContext).isInitialRedirectSupported(facesContext);
- }
-
- @Override
- public String interceptRedirect(FacesContext facesContext, String url)
- {
- return getClientWindow(facesContext).interceptRedirect(facesContext,
url);
- }
-
- protected ClientWindow getClientWindow(FacesContext facesContext)
- {
- ClientWindowRenderMode clientWindowRenderMode =
clientWindowConfig.getClientWindowRenderMode(facesContext);
-
- switch (clientWindowRenderMode)
- {
- case CLIENTWINDOW:
- return clientSideWindowStrategy;
- case CUSTOM:
- return null;
- case DELEGATED:
- return delegatedWindowStrategy;
- case LAZY:
- return lazyWindowStrategy;
- case NONE:
- return noneWindowStrategy;
- default:
- return null;
- }
- }
-}
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
deleted file mode 100644
index 8284de5ad..000000000
---
a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/window/strategy/AbstractClientWindowStrategy.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/*
- * 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.strategy;
-
-import java.util.Collections;
-import java.util.Map;
-import java.util.Random;
-import jakarta.annotation.PostConstruct;
-import jakarta.faces.context.FacesContext;
-import jakarta.inject.Inject;
-import jakarta.servlet.http.HttpServletRequest;
-
-import org.apache.deltaspike.core.util.StringUtils;
-import org.apache.deltaspike.jsf.api.config.JsfModuleConfig;
-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;
-
-public abstract class AbstractClientWindowStrategy implements ClientWindow
-{
- /**
- * This windowId will be used for all requests with disabled windowId
feature
- */
- public static final String DEFAULT_WINDOW_ID = "default";
-
- private static final String CACHE_QUERY_URL_PARAMETERS =
- "CACHE:" + AbstractClientWindowStrategy.class.getName() +
"#getQueryURLParameters";
- private static final String CACHE_WINDOW_ID =
- "CACHE:" + AbstractClientWindowStrategy.class.getName() +
".WindowId";
-
- private static final String
PER_USE_CLIENT_WINDOW_URL_QUERY_PARAMETER_DISABLED_KEY =
- LazyWindowStrategy.class.getName() +
".ClientWindowRenderModeEnablement";
-
- @Inject
- protected ClientWindowConfig clientWindowConfig;
-
- @Inject
- protected JsfModuleConfig jsfModuleConfig;
-
- private int maxWindowIdCount = 10;
-
- @PostConstruct
- protected void init()
- {
- this.maxWindowIdCount = ClientWindowHelper.getMaxWindowIdLength();
- }
-
- @Override
- public String getWindowId(FacesContext facesContext)
- {
- Map<String, Object> requestMap =
facesContext.getExternalContext().getRequestMap();
-
- // try to lookup from cache
- String windowId = (String) requestMap.get(CACHE_WINDOW_ID);
- if (windowId != null)
- {
- return windowId;
- }
-
- windowId = getOrCreateWindowId(facesContext);
-
-
- if (windowId != null)
- {
- windowId = sanitiseWindowId(windowId);
-
- // don't cut the windowId generated from JSF
- ClientWindowConfig.ClientWindowRenderMode clientWindowRenderMode =
- clientWindowConfig.getClientWindowRenderMode(facesContext);
- if
(!ClientWindowConfig.ClientWindowRenderMode.DELEGATED.equals(clientWindowRenderMode))
- {
- if (windowId.length() > this.maxWindowIdCount)
- {
- windowId = windowId.substring(0, this.maxWindowIdCount);
- }
- }
-
- requestMap.put(CACHE_WINDOW_ID, windowId);
- }
-
- return windowId;
- }
-
-
- /**
- * We have to escape some characters to make sure we do not open
- * any XSS vectors. E.g. replace (,<, & etc to
- * prevent attackers from injecting JavaScript function calls or html.
- */
- protected String sanitiseWindowId(String windowId)
- {
- return StringUtils.removeSpecialChars(windowId);
- }
-
- protected abstract String getOrCreateWindowId(FacesContext facesContext);
-
- protected String generateNewWindowId()
- {
- //X TODO proper mechanism
- return Integer.toString((new Random()).nextInt() % 10000);
- }
-
- protected String generateNewRequestToken()
- {
- return Integer.toString((int) Math.floor(Math.random() * 999));
- }
-
- protected boolean isPost(FacesContext facesContext)
- {
- if (facesContext.isPostback())
- {
- return true;
- }
-
- Object request = facesContext.getExternalContext().getRequest();
- if (request instanceof HttpServletRequest)
- {
- if ("POST".equals(((HttpServletRequest) request).getMethod()))
- {
- return true;
- }
- }
-
- return false;
- }
-
- protected String getWindowIdPostParameter(FacesContext facesContext)
- {
- Map<String, String> requestParams =
facesContext.getExternalContext().getRequestParameterMap();
- String windowId =
requestParams.get(ClientWindowHelper.RequestParameters.POST_WINDOW_ID);
-
- if (windowId == null)
- {
- windowId =
requestParams.get(ClientWindowHelper.RequestParameters.JSF_POST_WINDOW_ID);
- }
-
- return windowId;
- }
-
- protected String getWindowIdParameter(FacesContext facesContext)
- {
- Map<String, String> requestParameters =
facesContext.getExternalContext().getRequestParameterMap();
- return
requestParameters.get(ClientWindowHelper.RequestParameters.GET_WINDOW_ID);
- }
-
- @Override
- public void disableClientWindowRenderMode(FacesContext facesContext)
- {
- if (isSupportClientWindowRenderingMode())
- {
- Map<Object, Object> attrMap = facesContext.getAttributes();
-
attrMap.put(PER_USE_CLIENT_WINDOW_URL_QUERY_PARAMETER_DISABLED_KEY,
Boolean.TRUE);
- }
- }
-
- @Override
- public void enableClientWindowRenderMode(FacesContext facesContext)
- {
- if (isSupportClientWindowRenderingMode())
- {
- Map<Object, Object> attrMap = facesContext.getAttributes();
-
attrMap.remove(PER_USE_CLIENT_WINDOW_URL_QUERY_PARAMETER_DISABLED_KEY);
- }
- }
-
- @Override
- public boolean isClientWindowRenderModeEnabled(FacesContext facesContext)
- {
- if (isSupportClientWindowRenderingMode())
- {
- Map<Object, Object> attrMap = facesContext.getAttributes();
- return
!attrMap.containsKey(PER_USE_CLIENT_WINDOW_URL_QUERY_PARAMETER_DISABLED_KEY);
- }
-
- return false;
- }
-
- protected boolean isSupportClientWindowRenderingMode()
- {
- return false;
- }
-
- @Override
- public boolean isInitialRedirectSupported(FacesContext facesContext)
- {
- return false;
- }
-
- @Override
- public Map<String, String> getQueryURLParameters(FacesContext facesContext)
- {
- Map<String, String> cachedParameters =
- (Map<String, String>)
facesContext.getAttributes().get(CACHE_QUERY_URL_PARAMETERS);
-
- // cache paramters per request - will be called many times
- if (cachedParameters == null)
- {
- cachedParameters = createQueryURLParameters(facesContext);
- if (cachedParameters == null)
- {
- cachedParameters = Collections.EMPTY_MAP;
- }
-
- facesContext.getAttributes().put(CACHE_QUERY_URL_PARAMETERS,
cachedParameters);
- }
-
- return cachedParameters;
- }
-
- protected Map<String, String> createQueryURLParameters(FacesContext
facesContext)
- {
- return null;
- }
-
- @Override
- public String interceptRedirect(FacesContext facesContext, String url)
- {
- return ClientWindowHelper.appendWindowId(facesContext, url, this);
- }
-}
diff --git
a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/window/strategy/DelegatedWindowStrategy.java
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/window/strategy/DelegatedWindowStrategy.java
deleted file mode 100644
index 7c0b697e5..000000000
---
a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/window/strategy/DelegatedWindowStrategy.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.strategy;
-
-import jakarta.enterprise.context.Dependent;
-import jakarta.enterprise.inject.Typed;
-import jakarta.faces.context.FacesContext;
-
-@Dependent
-@Typed(DelegatedWindowStrategy.class)
-public class DelegatedWindowStrategy extends AbstractClientWindowStrategy
-{
- @Override
- protected String getOrCreateWindowId(FacesContext facesContext)
- {
- if (facesContext.getExternalContext().getClientWindow() != null)
- {
- return facesContext.getExternalContext().getClientWindow().getId();
- }
-
- return null;
- }
-}
diff --git
a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/window/strategy/NoneWindowStrategy.java
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/window/strategy/NoneWindowStrategy.java
deleted file mode 100644
index 890ab3be0..000000000
---
a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/window/strategy/NoneWindowStrategy.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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.strategy;
-
-import jakarta.enterprise.context.Dependent;
-import jakarta.enterprise.inject.Typed;
-import jakarta.faces.context.FacesContext;
-
-@Dependent
-@Typed(NoneWindowStrategy.class)
-public class NoneWindowStrategy extends AbstractClientWindowStrategy
-{
- @Override
- protected String getOrCreateWindowId(FacesContext facesContext)
- {
- return DEFAULT_WINDOW_ID;
- }
-
-}
diff --git
a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/util/ClientWindowHelper.java
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/util/ClientWindowHelper.java
index 9d58801ea..c5837772a 100644
---
a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/util/ClientWindowHelper.java
+++
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/util/ClientWindowHelper.java
@@ -27,9 +27,9 @@ import jakarta.enterprise.inject.Typed;
import jakarta.faces.FacesException;
import jakarta.faces.context.ExternalContext;
import jakarta.faces.context.FacesContext;
+import jakarta.faces.lifecycle.ClientWindow;
import org.apache.deltaspike.jsf.api.config.base.JsfBaseConfig;
-import org.apache.deltaspike.jsf.spi.scope.window.ClientWindow;
@Typed()
public abstract class ClientWindowHelper
diff --git
a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/view/DeltaSpikeViewHandler.java
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/view/DeltaSpikeViewHandler.java
index 021bdf3d4..784a4d8bd 100644
---
a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/view/DeltaSpikeViewHandler.java
+++
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/view/DeltaSpikeViewHandler.java
@@ -26,9 +26,8 @@ import jakarta.faces.application.ViewHandler;
import jakarta.faces.application.ViewHandlerWrapper;
import jakarta.faces.component.UIViewRoot;
import jakarta.faces.context.FacesContext;
-import org.apache.deltaspike.core.api.provider.BeanProvider;
+import jakarta.faces.lifecycle.ClientWindow;
import org.apache.deltaspike.jsf.impl.util.ClientWindowHelper;
-import org.apache.deltaspike.jsf.spi.scope.window.ClientWindow;
/**
* Aggregates all {@link ViewHandler} implementations provided by DeltaSpike
@@ -40,7 +39,6 @@ public class DeltaSpikeViewHandler extends ViewHandlerWrapper
implements Deactiv
private volatile Boolean initialized;
private ViewHandler securityAwareViewHandler;
- private ClientWindow clientWindow;
/**
* Constructor for wrapping the given {@link ViewHandler}
@@ -76,7 +74,13 @@ public class DeltaSpikeViewHandler extends
ViewHandlerWrapper implements Deactiv
lazyInit();
String actionURL = this.wrapped.getActionURL(context, viewId);
- return ClientWindowHelper.appendWindowId(context, actionURL,
clientWindow);
+
+ ClientWindow clientWindow =
context.getExternalContext().getClientWindow();
+ if (clientWindow != null)
+ {
+ return ClientWindowHelper.appendWindowId(context, actionURL,
clientWindow);
+ }
+ return actionURL;
}
@Override
@@ -107,8 +111,6 @@ public class DeltaSpikeViewHandler extends
ViewHandlerWrapper implements Deactiv
this.securityAwareViewHandler = null;
}
- this.clientWindow =
BeanProvider.getContextualReference(ClientWindow.class, true);
-
this.initialized = true;
}
}
diff --git
a/deltaspike/modules/jsf/impl/src/main/resources/META-INF/deltaspike.taglib.xml
b/deltaspike/modules/jsf/impl/src/main/resources/META-INF/deltaspike.taglib.xml
index 70fe5f20b..306d93588 100644
---
a/deltaspike/modules/jsf/impl/src/main/resources/META-INF/deltaspike.taglib.xml
+++
b/deltaspike/modules/jsf/impl/src/main/resources/META-INF/deltaspike.taglib.xml
@@ -30,13 +30,6 @@
<renderer-type>org.apache.deltaspike.WindowIdHolder</renderer-type>
</component>
</tag>
- <tag>
- <tag-name>disableClientWindow</tag-name>
- <component>
-
<component-type>org.apache.deltaspike.DisableClientWindow</component-type>
-
<renderer-type>org.apache.deltaspike.DisableClientWindow</renderer-type>
- </component>
- </tag>
<tag>
<tag-name>preventDoubleSubmit</tag-name>
<component>