Author: nbelaevski
Date: 2008-11-07 18:45:44 -0500 (Fri, 07 Nov 2008)
New Revision: 11060
Added:
trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/QueueRegistry.java
trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/QueueRenderer.java
Removed:
trunk/sandbox/ui/queue/src/main/java/org/ajax4jsf/taglib/html/facelets/
trunk/sandbox/ui/queue/src/main/java/org/ajax4jsf/taglib/html/jsp/
trunk/sandbox/ui/queue/src/main/java/org/richfaces/component/QueueDiscoveryVisitor.java
trunk/sandbox/ui/queue/src/main/java/org/richfaces/component/QueueRegistry.java
trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/QueueRenderer.java
trunk/sandbox/ui/queue/src/main/resources/META-INF/
trunk/sandbox/ui/queue/src/test/java/org/richfaces/component/
Modified:
trunk/sandbox/ui/queue/src/main/config/component/queue.xml
trunk/sandbox/ui/queue/src/main/java/org/richfaces/component/UIQueue.java
trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/scripts/QueueScriptResourceRenderer.java
Log:
Queue: discovery services & renderer implemented in draft
Modified: trunk/sandbox/ui/queue/src/main/config/component/queue.xml
===================================================================
--- trunk/sandbox/ui/queue/src/main/config/component/queue.xml 2008-11-07 23:44:42 UTC
(rev 11059)
+++ trunk/sandbox/ui/queue/src/main/config/component/queue.xml 2008-11-07 23:45:44 UTC
(rev 11060)
@@ -15,7 +15,7 @@
<superclass>org.ajax4jsf.webapp.taglib.HtmlComponentTagBase</superclass>
<test/>
</tag>
- <renderer>
+ <renderer generate="false">
<name>org.richfaces.QueueRenderer</name>
<classname>org.richfaces.renderkit.html.QueueRenderer</classname>
</renderer>
@@ -25,30 +25,63 @@
</taghandler>
-->
<property>
+ <name>enabled</name>
+ <classname>java.lang.Boolean</classname>
+ </property>
+ <property>
+ <name>size</name>
+ <classname>java.lang.Integer</classname>
+ </property>
+ <property>
<name>name</name>
<classname>java.lang.String</classname>
<defaultvalue>GLOBAL_QUEUE_NAME</defaultvalue>
</property>
+
<property>
<name>limitToList</name>
- <classname>boolean</classname>
+ <classname>java.lang.Boolean</classname>
</property>
<property >
<name>requestDelay</name>
- <classname>int</classname>
+ <classname>java.lang.Integer</classname>
</property>
<property>
<name>ignoreDupResponses</name>
- <classname>boolean</classname>
+ <classname>java.lang.Boolean</classname>
</property>
<property>
<name>timeout</name>
- <classname>int</classname>
+ <classname>java.lang.Integer</classname>
</property>
+
<property>
- <name>size</name>
- <classname>int</classname>
- <defaultvalue>1</defaultvalue>
+ <name>onsubmit</name>
+ <classname>java.lang.String</classname>
</property>
+ <property>
+ <name>oncomplete</name>
+ <classname>java.lang.String</classname>
+ </property>
+ <property>
+ <name>onbeforedomupdate</name>
+ <classname>java.lang.String</classname>
+ </property>
+ <property>
+ <name>sizeExceededBehavior</name>
+ <classname>java.lang.String</classname>
+ </property>
+ <property>
+ <name>onSizeExceeded</name>
+ <classname>java.lang.String</classname>
+ </property>
+ <property>
+ <name>onError</name>
+ <classname>java.lang.String</classname>
+ </property>
+ <property>
+ <name>onExpired</name>
+ <classname>java.lang.String</classname>
+ </property>
</component>
</components>
Deleted:
trunk/sandbox/ui/queue/src/main/java/org/richfaces/component/QueueDiscoveryVisitor.java
===================================================================
---
trunk/sandbox/ui/queue/src/main/java/org/richfaces/component/QueueDiscoveryVisitor.java 2008-11-07
23:44:42 UTC (rev 11059)
+++
trunk/sandbox/ui/queue/src/main/java/org/richfaces/component/QueueDiscoveryVisitor.java 2008-11-07
23:45:44 UTC (rev 11060)
@@ -1,98 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component;
-
-import java.util.List;
-
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.FacesContext;
-import javax.faces.event.PhaseEvent;
-
-import org.richfaces.event.RenderPhaseComponentVisitor;
-
-/**
- * <p>This visitor is intended to build lookup table for queues.</p>
- * <p>
- * The reason to use visitor and not queue component renderer is the fact that queue
lookup table will be
- * used by view components just after the start of view rendering. Render phase visitor
guarantees that component
- * placed in component tree <i>before</i> the queue can lookup the queue when
necessary.
- * </p>
- * @author Nick Belaevski
- * @since 3.3.0
- */
-
-//TODO create light version of component tree visitor for view root only
-public class QueueDiscoveryVisitor implements RenderPhaseComponentVisitor {
-
- /* (non-Javadoc)
- * @see
org.richfaces.event.RenderPhaseComponentVisitor#afterComponent(javax.faces.component.UIComponent,
javax.faces.event.PhaseEvent, java.lang.Object)
- */
- public void afterComponent(UIComponent component, PhaseEvent event,
- Object state) {
- // TODO Auto-generated method stub
-
- }
-
- /**
- * <p>
- * Collects all queue components and registers them in queue registry.
- * </p>
- * <p>
- * <b>Note:</b> assumes that queues can be used only as
<i>immediate</i> children of UIViewRoot
- * </p>
- * @see
org.richfaces.event.RenderPhaseComponentVisitor#afterRoot(javax.faces.event.PhaseEvent,
java.lang.Object)
- */
- public void afterRoot(PhaseEvent event, Object state) {
- FacesContext context = event.getFacesContext();
- UIViewRoot viewRoot = context.getViewRoot();
-
- if (viewRoot.getChildCount() > 0) {
- List<UIComponent> children = viewRoot.getChildren();
- for (UIComponent component : children) {
- if (component instanceof UIQueue) {
- UIQueue queue = (UIQueue) component;
-
- QueueRegistry.addQueue(context, queue);
- }
- }
- }
- }
-
- /* (non-Javadoc)
- * @see
org.richfaces.event.RenderPhaseComponentVisitor#beforeComponent(javax.faces.component.UIComponent,
javax.faces.event.PhaseEvent, java.lang.Object)
- */
- public void beforeComponent(UIComponent component, PhaseEvent event,
- Object state) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see
org.richfaces.event.RenderPhaseComponentVisitor#beforeRoot(javax.faces.event.PhaseEvent)
- */
- public Object beforeRoot(PhaseEvent event) {
- // TODO Auto-generated method stub
- return null;
- }
-
-}
Deleted: trunk/sandbox/ui/queue/src/main/java/org/richfaces/component/QueueRegistry.java
===================================================================
---
trunk/sandbox/ui/queue/src/main/java/org/richfaces/component/QueueRegistry.java 2008-11-07
23:44:42 UTC (rev 11059)
+++
trunk/sandbox/ui/queue/src/main/java/org/richfaces/component/QueueRegistry.java 2008-11-07
23:45:44 UTC (rev 11060)
@@ -1,78 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-
-package org.richfaces.component;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.faces.context.FacesContext;
-
-/**
- * @author Nick Belaevski
- * @since 3.3.0
- */
-public class QueueRegistry {
-
- private static final String QUEUE_DISCOVERY_SERVICE_ATTRIBUTE_NAME =
QueueRegistry.class.getName();
-
- public static void addQueue(FacesContext context, UIQueue queue) {
- Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
-
- Map<String, UIQueue> queuesMap = (Map<String, UIQueue>)
requestMap.get(QUEUE_DISCOVERY_SERVICE_ATTRIBUTE_NAME);
- if (queuesMap == null) {
- queuesMap = new HashMap<String, UIQueue>();
-
- requestMap.put(QUEUE_DISCOVERY_SERVICE_ATTRIBUTE_NAME, queuesMap);
- }
-
- queuesMap.put(queue.getName(), queue);
- }
-
- public static UIQueue getQueue(FacesContext context, String name) {
- UIQueue result = null;
-
- Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
-
- Map<String, UIQueue> queuesMap = (Map<String, UIQueue>)
requestMap.get(QUEUE_DISCOVERY_SERVICE_ATTRIBUTE_NAME);
- if (queuesMap != null) {
- result = queuesMap.get(name);
- }
-
- return result;
- }
-
- public static UIQueue[] getQueues(FacesContext context) {
- UIQueue[] result = null;
-
- Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
-
- Map<String, UIQueue> queuesMap = (Map<String, UIQueue>)
requestMap.get(QUEUE_DISCOVERY_SERVICE_ATTRIBUTE_NAME);
- if (queuesMap != null) {
- Collection<UIQueue> queues = queuesMap.values();
- result = queues.toArray(new UIQueue[queues.size()]);
- }
-
- return result;
- }
-}
Modified: trunk/sandbox/ui/queue/src/main/java/org/richfaces/component/UIQueue.java
===================================================================
--- trunk/sandbox/ui/queue/src/main/java/org/richfaces/component/UIQueue.java 2008-11-07
23:44:42 UTC (rev 11059)
+++ trunk/sandbox/ui/queue/src/main/java/org/richfaces/component/UIQueue.java 2008-11-07
23:45:44 UTC (rev 11060)
@@ -21,29 +21,28 @@
package org.richfaces.component;
+import javax.faces.component.NamingContainer;
import javax.faces.component.UIComponent;
import javax.faces.component.UIComponentBase;
+import javax.faces.component.UIForm;
import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
/**
* @author Nick Belaevski
* @since 3.3.0
*/
-public abstract class UIQueue extends UIComponentBase {
+public abstract class UIQueue extends UIComponentBase {
public static final String COMPONENT_TYPE = "org.richfaces.Queue";
public static final String COMPONENT_FAMILY = "org.richfaces.Queue";
- //That is used in JavaScript code also
public static final String GLOBAL_QUEUE_NAME = "org.richfaces.queue.global";
public abstract String getName();
public abstract void setName(String name);
- public abstract int getSize();
- public abstract void setSize(int size);
-
@Override
public String getFamily() {
return COMPONENT_FAMILY;
@@ -51,11 +50,20 @@
@Override
public void setParent(UIComponent parent) {
- if (!(parent instanceof UIViewRoot)) {
+ if (parent != null && !(parent instanceof UIViewRoot) && !(parent
instanceof UIForm)) {
throw new IllegalArgumentException("Queue component:" +
getClientId(getFacesContext()) +
- " should have UIViewRoot as its immediate parent");
+ " should have UIViewRoot or UIForm as its immediate parent");
}
super.setParent(parent);
}
+
+ public String getClientName(FacesContext context) {
+ UIComponent parent = getParent();
+ if (parent instanceof UIForm) {
+ return parent.getClientId(context) + NamingContainer.SEPARATOR_CHAR + getName();
+ } else {
+ return context.getExternalContext().encodeNamespace(getName());
+ }
+ }
}
Added:
trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/QueueRegistry.java
===================================================================
--- trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/QueueRegistry.java
(rev 0)
+++
trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/QueueRegistry.java 2008-11-07
23:45:44 UTC (rev 11060)
@@ -0,0 +1,64 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+package org.richfaces.renderkit.html;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.0
+ */
+public class QueueRegistry {
+
+ private static final String REGISTRY_ATTRIBUTE_NAME = QueueRegistry.class.getName();
+
+ public static void registerQueue(FacesContext context, String clientName, Object data)
{
+ ExternalContext externalContext = context.getExternalContext();
+ Map<String, Object> requestMap = externalContext.getRequestMap();
+
+ Map<String, Object> registryMap = (Map<String, Object>)
+ requestMap.get(REGISTRY_ATTRIBUTE_NAME);
+
+ if (registryMap == null) {
+ registryMap = new LinkedHashMap<String, Object>();
+ requestMap.put(REGISTRY_ATTRIBUTE_NAME, registryMap);
+ }
+
+ if (!registryMap.containsKey(clientName)) {
+ registryMap.put(clientName, data);
+ } else {
+ throw new IllegalArgumentException("Queue with name '" + clientName +
"' has already been registered");
+ }
+ }
+
+ public static Map<String, Object> getRegisteredQueues(FacesContext context) {
+ ExternalContext externalContext = context.getExternalContext();
+ Map<String, Object> requestMap = externalContext.getRequestMap();
+
+ return (Map<String, Object>) requestMap.get(REGISTRY_ATTRIBUTE_NAME);
+ }
+}
Deleted:
trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/QueueRenderer.java
===================================================================
---
trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/QueueRenderer.java 2008-11-07
23:44:42 UTC (rev 11059)
+++
trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/QueueRenderer.java 2008-11-07
23:45:44 UTC (rev 11060)
@@ -1,61 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.renderkit.html;
-
-import javax.faces.component.UIComponent;
-
-import org.ajax4jsf.javascript.AjaxScript;
-import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
-import org.ajax4jsf.resource.InternetResource;
-import org.richfaces.component.UIQueue;
-import org.richfaces.renderkit.html.scripts.QueueScript;
-
-/**
- * @author Nick Belaevski
- * @since 3.3.0
- */
-public class QueueRenderer extends HeaderResourcesRendererBase {
-
- private volatile InternetResource[] scripts;
-
- @Override
- protected InternetResource[] getScripts() {
- if (scripts == null) {
- synchronized (this) {
- if (scripts == null) {
- scripts = new InternetResource[] {
- getResource(AjaxScript.class.getName()),
- getResource(QueueScript.class.getName())
- };
- }
- }
- }
-
- return scripts;
- }
-
- @Override
- protected Class<? extends UIComponent> getComponentClass() {
- return UIQueue.class;
- }
-
-}
Copied:
trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/QueueRenderer.java (from
rev 10990,
trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/QueueRenderer.java)
===================================================================
--- trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/QueueRenderer.java
(rev 0)
+++
trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/QueueRenderer.java 2008-11-07
23:45:44 UTC (rev 11060)
@@ -0,0 +1,142 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit.html;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.javascript.AjaxScript;
+import org.ajax4jsf.javascript.JSFunctionDefinition;
+import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
+import org.ajax4jsf.resource.InternetResource;
+import org.richfaces.component.UIQueue;
+import org.richfaces.renderkit.html.scripts.QueueScript;
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.0
+ */
+public class QueueRenderer extends HeaderResourcesRendererBase {
+
+ private static final String[] PLAIN_ATTRIBUTES = new String[] {
+ "enabled",
+ "size",
+ "sizeExceededBehavior",
+ "requestDelay",
+ "timeout",
+ "ignoreDupResponses",
+ "limitToList",
+ };
+
+ private static final String[] FUNCTION_ATTRIBUTES = new String[] {
+ "onsubmit",
+ "oncomplete",
+ "onbeforedomupdate",
+ "onSizeExceeded",
+ "onError",
+ "onExpired"
+ };
+
+
+
+ private volatile InternetResource[] scripts;
+
+ @Override
+ protected InternetResource[] getScripts() {
+ if (scripts == null) {
+ synchronized (this) {
+ if (scripts == null) {
+ scripts = new InternetResource[] {
+ getResource(AjaxScript.class.getName()),
+ getResource(QueueScript.class.getName())
+ };
+ }
+ }
+ }
+
+ return scripts;
+ }
+
+ @Override
+ protected Class<? extends UIComponent> getComponentClass() {
+ return UIQueue.class;
+ }
+
+ private boolean isNotEmpty(Object object) {
+ if (object == null) {
+ return false;
+ }
+
+ if (object instanceof String) {
+ String s = (String) object;
+ if (s.length() == 0) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ private Object createRendererData(FacesContext context, UIQueue queue) {
+ Map<String, Object> attributes = queue.getAttributes();
+
+ Map<String,Object> data = new HashMap<String, Object>();
+
+ for (String attributeName : PLAIN_ATTRIBUTES) {
+ Object value = attributes.get(attributeName);
+ if (isNotEmpty(value)) {
+ data.put(attributeName, value);
+ }
+ }
+
+ for (String attributeName : FUNCTION_ATTRIBUTES) {
+ Object value = attributes.get(attributeName);
+ if (isNotEmpty(value)) {
+ //TODO nick - apply proper functions signature
+ data.put(attributeName, new
JSFunctionDefinition("event").addToBody(value));
+ }
+ }
+
+ return data;
+ }
+
+ @Override
+ public void encodeBegin(FacesContext context, UIComponent component)
+ throws IOException {
+ super.encodeBegin(context, component);
+ }
+
+ @Override
+ public void encodeEnd(FacesContext context, UIComponent component)
+ throws IOException {
+ super.encodeEnd(context, component);
+
+ UIQueue queue = (UIQueue) component;
+
+ QueueRegistry.registerQueue(context, queue.getClientName(context),
+ createRendererData(context, queue));
+ }
+}
Property changes on:
trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/QueueRenderer.java
___________________________________________________________________
Name: svn:mergeinfo
+
Modified:
trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/scripts/QueueScriptResourceRenderer.java
===================================================================
---
trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/scripts/QueueScriptResourceRenderer.java 2008-11-07
23:44:42 UTC (rev 11059)
+++
trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/scripts/QueueScriptResourceRenderer.java 2008-11-07
23:45:44 UTC (rev 11060)
@@ -25,8 +25,8 @@
import java.io.IOException;
import java.util.Collections;
import java.util.Map;
+import java.util.Map.Entry;
-import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
@@ -35,8 +35,6 @@
import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.ajax4jsf.resource.BaseResourceRenderer;
import org.ajax4jsf.resource.InternetResource;
-import org.richfaces.component.QueueRegistry;
-import org.richfaces.component.UIQueue;
/**
* @author Nick Belaevski
@@ -55,9 +53,9 @@
if (requestMap.get(resourceKey) == null) {
requestMap.put(resourceKey, Boolean.TRUE);
- UIQueue[] queues = QueueRegistry.getQueues(context);
+ Map<String, Object> queues =
org.richfaces.renderkit.html.QueueRegistry.getRegisteredQueues(context);
- if (queues != null && queues.length != 0) {
+ if (queues != null && !queues.isEmpty()) {
super.encode(resource, context, queues, attributes);
}
}
@@ -83,15 +81,12 @@
FacesContext context, Object data) throws IOException {
ResponseWriter writer = context.getResponseWriter();
- ExternalContext externalContext = context.getExternalContext();
- UIQueue[] queues = (UIQueue[]) data;
+ Map<String, Object> queues = (Map<String, Object>) data;
- for (UIQueue queue : queues) {
- String name = externalContext.encodeNamespace(queue.getName());
- int size = queue.getSize();
+ for (Entry<String, Object> entry : queues.entrySet()) {
writer.writeText("A4J.AJAX.EventQueue.addQueue(", null);
- writer.writeText(new JSObject("A4J.AJAX.EventQueue", name, size).toScript(),
null);
+ writer.writeText(new JSObject("A4J.AJAX.EventQueue", entry.getKey(),
entry.getValue()).toScript(), null);
writer.writeText(");", null);
}