Updated Branches: refs/heads/master 1ee1d9cbf -> d20060e5c
DELTASPIKE-500 Implement ds:disableClientWindow Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/d20060e5 Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/d20060e5 Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/d20060e5 Branch: refs/heads/master Commit: d20060e5c5417aa720214c5d0130b9b583aa754c Parents: 1ee1d9c Author: tandraschko <[email protected]> Authored: Sun Jan 19 13:31:43 2014 +0100 Committer: tandraschko <[email protected]> Committed: Sun Jan 19 13:31:43 2014 +0100 ---------------------------------------------------------------------- .../window/DisableClientWindowComponent.java | 28 ++++++++ .../window/DisableClientWindowHtmlRenderer.java | 76 ++++++++++++++++++++ .../resources/META-INF/deltaspike.taglib.xml | 7 ++ 3 files changed, 111 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d20060e5/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/component/window/DisableClientWindowComponent.java ---------------------------------------------------------------------- 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 new file mode 100644 index 0000000..c664b11 --- /dev/null +++ b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/component/window/DisableClientWindowComponent.java @@ -0,0 +1,28 @@ +/* + * 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 javax.faces.component.FacesComponent; +import javax.faces.component.UIOutput; + +@FacesComponent(DisableClientWindowComponent.COMPONENT_TYPE) +public class DisableClientWindowComponent extends UIOutput +{ + public static final String COMPONENT_TYPE = "org.apache.deltaspike.DisableClientWindow"; +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d20060e5/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 new file mode 100644 index 0000000..efd3cdc --- /dev/null +++ b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/component/window/DisableClientWindowHtmlRenderer.java @@ -0,0 +1,76 @@ +/* + * 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 javax.faces.component.UIComponent; +import javax.faces.context.FacesContext; +import javax.faces.render.FacesRenderer; +import javax.faces.render.Renderer; +import org.apache.deltaspike.core.api.provider.BeanProvider; +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 ClientWindow clientWindow; + + @Override + public void encodeChildren(FacesContext context, UIComponent component) throws IOException + { + boolean isEnabled = getClientWindow().isClientWindowRenderModeEnabled(context); + + if (isEnabled) + { + try + { + getClientWindow().disableClientWindowRenderMode(context); + + super.encodeChildren(context, component); + } + finally + { + getClientWindow().enableClientWindowRenderMode(context); + } + } + } + + @Override + public boolean getRendersChildren() + { + return true; + } + + private ClientWindow getClientWindow() + { + if (clientWindow == null) + { + synchronized (this) + { + if (clientWindow == null) + { + clientWindow = BeanProvider.getContextualReference(ClientWindow.class); + } + } + } + + return clientWindow; + } +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d20060e5/deltaspike/modules/jsf/impl/src/main/resources/META-INF/deltaspike.taglib.xml ---------------------------------------------------------------------- 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 69dab0b..b1cfc44 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,4 +30,11 @@ <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> </facelet-taglib>
