Author: nbelaevski
Date: 2010-09-20 04:09:38 -0400 (Mon, 20 Sep 2010)
New Revision: 19260
Removed:
trunk/ui/core/ui/src/main/java/org/richfaces/component/QueuePreRenderViewListener.java
trunk/ui/core/ui/src/main/resources/META-INF/queue-prender-listener.faces-config.xml
Modified:
trunk/ui/core/ui/src/main/java/org/richfaces/renderkit/html/QueueRendererBase.java
Log:
https://jira.jboss.org/browse/RF-9341
Deleted:
trunk/ui/core/ui/src/main/java/org/richfaces/component/QueuePreRenderViewListener.java
===================================================================
---
trunk/ui/core/ui/src/main/java/org/richfaces/component/QueuePreRenderViewListener.java 2010-09-19
01:21:32 UTC (rev 19259)
+++
trunk/ui/core/ui/src/main/java/org/richfaces/component/QueuePreRenderViewListener.java 2010-09-20
08:09:38 UTC (rev 19260)
@@ -1,68 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.richfaces.component;
-
-import static
org.richfaces.application.configuration.ConfigurationServiceHelper.getBooleanConfigurationValue;
-
-import javax.faces.application.Application;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIOutput;
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.FacesContext;
-import javax.faces.event.AbortProcessingException;
-import javax.faces.event.SystemEvent;
-import javax.faces.event.SystemEventListener;
-
-import org.richfaces.application.CommonComponentsConfiguration;
-
-/**
- * @author Nick Belaevski
- *
- */
-public class QueuePreRenderViewListener implements SystemEventListener {
-
- private static final String QUEUE_RESOURCE_COMPONENT_RENDERER_TYPE =
"org.richfaces.QueueResourceComponentRenderer";
-
- public boolean isListenerForSource(Object source) {
- return true;
- }
-
- public void processEvent(SystemEvent event) throws AbortProcessingException {
- FacesContext context = FacesContext.getCurrentInstance();
- UIViewRoot viewRoot = context.getViewRoot();
-
- boolean queueEnabled = getBooleanConfigurationValue(context,
CommonComponentsConfiguration.Items.queueEnabled);
- if (queueEnabled) {
- Application application = context.getApplication();
- UIComponent queueResourceComponent = application.createComponent(context,
- UIOutput.COMPONENT_TYPE, QUEUE_RESOURCE_COMPONENT_RENDERER_TYPE);
-
- //fix for JSF duplicate ID exception
- queueResourceComponent.setId(QueueRegistry.QUEUE_SCRIPT_ID);
-
- viewRoot.addComponentResource(context, queueResourceComponent);
- } else {
- //queue can be switched off at application level, not a page level, so no
need to remove it if it is switched off
- }
- }
-
-}
Modified:
trunk/ui/core/ui/src/main/java/org/richfaces/renderkit/html/QueueRendererBase.java
===================================================================
---
trunk/ui/core/ui/src/main/java/org/richfaces/renderkit/html/QueueRendererBase.java 2010-09-19
01:21:32 UTC (rev 19259)
+++
trunk/ui/core/ui/src/main/java/org/richfaces/renderkit/html/QueueRendererBase.java 2010-09-20
08:09:38 UTC (rev 19260)
@@ -23,8 +23,12 @@
import static
org.richfaces.application.configuration.ConfigurationServiceHelper.getBooleanConfigurationValue;
+import java.util.List;
+
+import javax.faces.application.Application;
import javax.faces.application.ResourceDependency;
import javax.faces.component.UIComponent;
+import javax.faces.component.UIOutput;
import javax.faces.context.FacesContext;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.ComponentSystemEvent;
@@ -55,6 +59,28 @@
protected static final String NAME_ATTRIBBUTE = "name";
protected static final Logger LOGGER = RichfacesLogger.COMPONENTS.getLogger();
+ private static final String QUEUE_RESOURCE_COMPONENT_RENDERER_TYPE =
"org.richfaces.QueueResourceComponentRenderer";
+ private static final String QUEUE_RESOURCE_COMPONENT_TARGET = "head";
+
+ private void addQueueResourceComponent(FacesContext context) {
+ List<UIComponent> resources =
context.getViewRoot().getComponentResources(context, QUEUE_RESOURCE_COMPONENT_TARGET);
+
+ for (UIComponent resource: resources) {
+ if
(QUEUE_RESOURCE_COMPONENT_RENDERER_TYPE.equals(resource.getRendererType())) {
+ return;
+ }
+ }
+
+ Application application = context.getApplication();
+ UIComponent queueResourceComponent = application.createComponent(context,
+ UIOutput.COMPONENT_TYPE, QUEUE_RESOURCE_COMPONENT_RENDERER_TYPE);
+
+ //fix for JSF duplicate ID exception
+ queueResourceComponent.setId(QueueRegistry.QUEUE_SCRIPT_ID);
+
+ context.getViewRoot().addComponentResource(context, queueResourceComponent,
QUEUE_RESOURCE_COMPONENT_TARGET);
+ }
+
public void processEvent(ComponentSystemEvent event) throws AbortProcessingException
{
FacesContext context = FacesContext.getCurrentInstance();
@@ -69,6 +95,7 @@
if (event instanceof PostAddToViewEvent) {
queueRegistry.addQueue(queueName, comp);
+ addQueueResourceComponent(context);
} else if (event instanceof PreRemoveFromViewEvent) {
queueRegistry.removeQueue(queueName);
}
Deleted:
trunk/ui/core/ui/src/main/resources/META-INF/queue-prender-listener.faces-config.xml
===================================================================
---
trunk/ui/core/ui/src/main/resources/META-INF/queue-prender-listener.faces-config.xml 2010-09-19
01:21:32 UTC (rev 19259)
+++
trunk/ui/core/ui/src/main/resources/META-INF/queue-prender-listener.faces-config.xml 2010-09-20
08:09:38 UTC (rev 19260)
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<faces-config
xmlns="http://java.sun.com/xml/ns/javaee"
- version="2.0">
-
- <application>
- <system-event-listener>
- <system-event-listener-class>org.richfaces.component.QueuePreRenderViewListener</system-event-listener-class>
- <system-event-class>javax.faces.event.PreRenderViewEvent</system-event-class>
- </system-event-listener>
- </application>
-</faces-config>
\ No newline at end of file