Author: dmorozov
Date: 2008-11-10 12:06:53 -0500 (Mon, 10 Nov 2008)
New Revision: 11070
Added:
trunk/sandbox/samples/queue-sample/src/main/java/org/richfaces/OversizeBean.java
trunk/sandbox/samples/queue-sample/src/main/webapp/pages/sized-queue.xhtml
trunk/sandbox/samples/queue-sample/src/main/webapp/templates/navigation.xhtml
trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/QueueRendererData.java
trunk/sandbox/ui/queue/src/test/java/org/richfaces/ScriptTest.java
Modified:
trunk/sandbox/samples/queue-sample/src/main/webapp/WEB-INF/faces-config.xml
trunk/sandbox/samples/queue-sample/src/main/webapp/index.jsp
trunk/sandbox/samples/queue-sample/src/main/webapp/pages/form-queue.xhtml
trunk/sandbox/samples/queue-sample/src/main/webapp/pages/index.xhtml
trunk/sandbox/samples/queue-sample/src/main/webapp/pages/view-queue.xhtml
trunk/sandbox/samples/queue-sample/src/main/webapp/templates/index.xhtml
trunk/sandbox/ui/queue/pom.xml
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
trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/scripts/QueueScriptResourceRenderer.java
Log:
https://jira.jboss.org/jira/browse/RF-4854
Added: trunk/sandbox/samples/queue-sample/src/main/java/org/richfaces/OversizeBean.java
===================================================================
--- trunk/sandbox/samples/queue-sample/src/main/java/org/richfaces/OversizeBean.java
(rev 0)
+++
trunk/sandbox/samples/queue-sample/src/main/java/org/richfaces/OversizeBean.java 2008-11-10
17:06:53 UTC (rev 11070)
@@ -0,0 +1,62 @@
+/**
+ * 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;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+
+public class OversizeBean {
+ public String[] getQueueNames() {
+ return new String[] {
+ "dropNext", "dropNew", "fireNext", "fireNew"
+ };
+ }
+
+ private Map<String, String> queueData = new HashMap<String, String>();
+
+ public Map<String, String> getQueueData() {
+ return queueData;
+ }
+
+ public void reset() {
+ this.queueData = new HashMap<String, String>();
+ }
+
+ public void action() {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ ExternalContext externalContext = facesContext.getExternalContext();
+ Map<String, String> requestParameterMap =
externalContext.getRequestParameterMap();
+
+ String queueName = (String) requestParameterMap.get("queueName");
+ String sequence = (String) requestParameterMap.get("sequence");
+
+ String queueString = queueData.get(queueName);
+ if (queueString == null) {
+ queueData.put(queueName, sequence);
+ } else {
+ queueData.put(queueName, queueString + ", " + sequence);
+ }
+ }
+}
Modified: trunk/sandbox/samples/queue-sample/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- trunk/sandbox/samples/queue-sample/src/main/webapp/WEB-INF/faces-config.xml 2008-11-10
17:04:25 UTC (rev 11069)
+++ trunk/sandbox/samples/queue-sample/src/main/webapp/WEB-INF/faces-config.xml 2008-11-10
17:06:53 UTC (rev 11070)
@@ -8,6 +8,12 @@
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
+ <managed-bean>
+ <managed-bean-name>oversizeBean</managed-bean-name>
+ <managed-bean-class>org.richfaces.OversizeBean</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
+
<application>
<view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
</application>
Modified: trunk/sandbox/samples/queue-sample/src/main/webapp/index.jsp
===================================================================
--- trunk/sandbox/samples/queue-sample/src/main/webapp/index.jsp 2008-11-10 17:04:25 UTC
(rev 11069)
+++ trunk/sandbox/samples/queue-sample/src/main/webapp/index.jsp 2008-11-10 17:06:53 UTC
(rev 11070)
@@ -1,11 +1,3 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-
-<html>
-
-<head></head>
-
- <body>
- <jsp:forward page="/pages/index.jsf" />
- </body>
-
-</html>
\ No newline at end of file
+<%
+ response.sendRedirect("pages/index.jsf");
+%>
\ No newline at end of file
Modified: trunk/sandbox/samples/queue-sample/src/main/webapp/pages/form-queue.xhtml
===================================================================
--- trunk/sandbox/samples/queue-sample/src/main/webapp/pages/form-queue.xhtml 2008-11-10
17:04:25 UTC (rev 11069)
+++ trunk/sandbox/samples/queue-sample/src/main/webapp/pages/form-queue.xhtml 2008-11-10
17:06:53 UTC (rev 11070)
@@ -22,6 +22,8 @@
</head>
<body>
<f:view>
+ <ui:include src="/templates/navigation.xhtml" />
+
<a4j:status startText="...running..." startStyle="color: green"
for="region" />
<ui:decorate template="/templates/index.xhtml">
Modified: trunk/sandbox/samples/queue-sample/src/main/webapp/pages/index.xhtml
===================================================================
--- trunk/sandbox/samples/queue-sample/src/main/webapp/pages/index.xhtml 2008-11-10
17:04:25 UTC (rev 11069)
+++ trunk/sandbox/samples/queue-sample/src/main/webapp/pages/index.xhtml 2008-11-10
17:06:53 UTC (rev 11070)
@@ -22,6 +22,8 @@
</head>
<body>
<f:view>
+ <ui:include src="/templates/navigation.xhtml" />
+
<a4j:status startText="...running..." startStyle="color: green"
for="region" />
<ui:decorate template="/templates/index.xhtml">
Added: trunk/sandbox/samples/queue-sample/src/main/webapp/pages/sized-queue.xhtml
===================================================================
--- trunk/sandbox/samples/queue-sample/src/main/webapp/pages/sized-queue.xhtml
(rev 0)
+++ trunk/sandbox/samples/queue-sample/src/main/webapp/pages/sized-queue.xhtml 2008-11-10
17:06:53 UTC (rev 11070)
@@ -0,0 +1,93 @@
+<html
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:c="http://java.sun.com/jstl/core"
+
xmlns:q="http://labs.jboss.com/jbossrichfaces/ui/ui/queue">
+ <head>
+ <title></title>
+ <script type="text/javascript">
+ function findLog() {
+ return document.getElementById('logConsole');
+ }
+
+ function hideLog() {
+ findLog().style.display = 'none';
+ }
+
+ function showLog() {
+ findLog().style.display = '';
+ }
+ </script>
+ </head>
+ <body>
+ <f:view>
+ <ui:include src="/templates/navigation.xhtml" />
+
+ <a4j:status startText="...running..." stopText="stopped"
startStyle="color: green" />
+
+ <c:set var="size" value="1" />
+ <c:set var="requestDelay" value="1500" />
+
+ <c:forEach items="#{oversizeBean.queueNames}"
var="queueName">
+ <q:queue requestDelay="#{requestDelay}" size="#{size}"
name="#{queueName}"
+ sizeExceededBehavior="#{queueName}"/>
+ </c:forEach>
+
+ <script type="text/javascript">
+ function initSequences() {
+ window.sequences = {
+ dropNext: 0,
+ dropNew: 0,
+ fireNext: 0,
+ fireNew: 0
+ };
+ }
+
+ initSequences();
+ </script>
+
+ <h:panelGroup id="queueStatus">
+ <table style="width: 50%;"><tbody>
+ <tr style="width: 25%">
+ <a4j:repeat value="#{oversizeBean.queueNames}"
var="queueName">
+ <td>
+ #{queueName}
+ </td>
+ </a4j:repeat>
+ </tr>
+ <tr>
+ <a4j:repeat value="#{oversizeBean.queueNames}"
var="queueName">
+ <td>
+ #{oversizeBean.queueData[queueName]} 
+ </td>
+ </a4j:repeat>
+ </tr>
+ </tbody></table>
+ </h:panelGroup>
+
+ <h:form>
+ <c:forEach items="#{oversizeBean.queueNames}"
var="queueName">
+ <button onclick="#{queueName}Fire1();#{queueName}Fire2(); return
false;">
+ #{queueName}
+ </button>
+ <c:forEach begin="1" end="2" var="index">
+ <a4j:jsFunction action="#{oversizeBean.action}"
+ name="#{queueName}Fire#{index}"
+ reRender="queueStatus" eventsQueue="#{queueName}">
+ <a4j:actionparam name="sequence"
value="sequences.#{queueName}++" noEscape="true" />
+ <a4j:actionparam name="queueName"
value="#{queueName}"/>
+ </a4j:jsFunction>
+ </c:forEach>
+   
+ </c:forEach>
+
+ <br />
+
+ <a4j:commandButton value="reset" reRender="queueStatus"
action="#{oversizeBean.reset}" oncomplete="initSequences()"/>
+ </h:form>
+
+ </f:view>
+ </body>
+</html>
Modified: trunk/sandbox/samples/queue-sample/src/main/webapp/pages/view-queue.xhtml
===================================================================
--- trunk/sandbox/samples/queue-sample/src/main/webapp/pages/view-queue.xhtml 2008-11-10
17:04:25 UTC (rev 11069)
+++ trunk/sandbox/samples/queue-sample/src/main/webapp/pages/view-queue.xhtml 2008-11-10
17:06:53 UTC (rev 11070)
@@ -22,6 +22,8 @@
</head>
<body>
<f:view>
+ <ui:include src="/templates/navigation.xhtml" />
+
<a4j:status startText="...running..." startStyle="color: green"
for="region" />
<ui:decorate template="/templates/index.xhtml">
Modified: trunk/sandbox/samples/queue-sample/src/main/webapp/templates/index.xhtml
===================================================================
--- trunk/sandbox/samples/queue-sample/src/main/webapp/templates/index.xhtml 2008-11-10
17:04:25 UTC (rev 11069)
+++ trunk/sandbox/samples/queue-sample/src/main/webapp/templates/index.xhtml 2008-11-10
17:06:53 UTC (rev 11070)
@@ -6,6 +6,7 @@
xmlns:q="http://labs.jboss.com/jbossrichfaces/ui/ui/queue">
<ui:composition>
+
<h2><ui:insert name="title" /></h2>
<ui:insert name="viewQueue" />
Added: trunk/sandbox/samples/queue-sample/src/main/webapp/templates/navigation.xhtml
===================================================================
--- trunk/sandbox/samples/queue-sample/src/main/webapp/templates/navigation.xhtml
(rev 0)
+++
trunk/sandbox/samples/queue-sample/src/main/webapp/templates/navigation.xhtml 2008-11-10
17:06:53 UTC (rev 11070)
@@ -0,0 +1,19 @@
+<html
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:q="http://labs.jboss.com/jbossrichfaces/ui/ui/queue">
+
+ <ui:composition>
+ <h:outputLink value="index.jsf">No global queues
page</h:outputLink>
+ <h:outputText value=" " />
+ <h:outputLink value="form-queue.jsf">Form global
queue</h:outputLink>
+ <h:outputText value=" " />
+ <h:outputLink value="view-queue.jsf">View global
queue</h:outputLink>
+ <h:outputText value=" " />
+ <h:outputLink value="sized-queue.jsf">Size exceed
behaviors</h:outputLink>
+
+ <br />
+ </ui:composition>
+</html>
Modified: trunk/sandbox/ui/queue/pom.xml
===================================================================
--- trunk/sandbox/ui/queue/pom.xml 2008-11-10 17:04:25 UTC (rev 11069)
+++ trunk/sandbox/ui/queue/pom.xml 2008-11-10 17:06:53 UTC (rev 11070)
@@ -46,5 +46,10 @@
<artifactId>richfaces-impl</artifactId>
<version>3.3.0-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.richfaces.ui</groupId>
+ <artifactId>core</artifactId>
+ <version>3.3.0-SNAPSHOT</version>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
Modified:
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 2008-11-10
17:04:25 UTC (rev 11069)
+++
trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/QueueRegistry.java 2008-11-10
17:06:53 UTC (rev 11070)
@@ -36,15 +36,15 @@
private static final String REGISTRY_ATTRIBUTE_NAME = QueueRegistry.class.getName();
- public static void registerQueue(FacesContext context, String clientName, Object data)
{
+ public static void registerQueue(FacesContext context, String clientName,
QueueRendererData data) {
ExternalContext externalContext = context.getExternalContext();
Map<String, Object> requestMap = externalContext.getRequestMap();
- Map<String, Object> registryMap = (Map<String, Object>)
+ Map<String, QueueRendererData> registryMap = (Map<String,
QueueRendererData>)
requestMap.get(REGISTRY_ATTRIBUTE_NAME);
if (registryMap == null) {
- registryMap = new LinkedHashMap<String, Object>();
+ registryMap = new LinkedHashMap<String, QueueRendererData>();
requestMap.put(REGISTRY_ATTRIBUTE_NAME, registryMap);
}
@@ -55,10 +55,10 @@
}
}
- public static Map<String, Object> getRegisteredQueues(FacesContext context) {
+ public static Map<String, QueueRendererData> getRegisteredQueues(FacesContext
context) {
ExternalContext externalContext = context.getExternalContext();
Map<String, Object> requestMap = externalContext.getRequestMap();
- return (Map<String, Object>) requestMap.get(REGISTRY_ATTRIBUTE_NAME);
+ return (Map<String, QueueRendererData>) requestMap.get(REGISTRY_ATTRIBUTE_NAME);
}
}
Modified:
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-10
17:04:25 UTC (rev 11069)
+++
trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/QueueRenderer.java 2008-11-10
17:06:53 UTC (rev 11070)
@@ -22,7 +22,6 @@
package org.richfaces.renderkit.html;
import java.io.IOException;
-import java.util.HashMap;
import java.util.Map;
import javax.faces.component.UIComponent;
@@ -41,27 +40,31 @@
*/
public class QueueRenderer extends HeaderResourcesRendererBase {
- private static final String[] PLAIN_ATTRIBUTES = new String[] {
+ private static final String[] QUEUE_ATTRIBUTES = new String[] {
"enabled",
"size",
- "sizeExceededBehavior",
+ "sizeExceededBehavior"
+ };
+
+ private static final String[] QUEUE_FUNCTION_ATTRIBUTES = new String[] {
+ "onSizeExceeded",
+ "onError",
+ "onExpired"
+ };
+
+ private static final String[] REQUEST_ATTRIBUTES = new String[] {
"requestDelay",
"timeout",
"ignoreDupResponses",
- "limitToList",
+ "limitToList"
};
- private static final String[] FUNCTION_ATTRIBUTES = new String[] {
+ private static final String[] REQUEST_FUNCTION_ATTRIBUTES = new String[] {
"onsubmit",
"oncomplete",
"onbeforedomupdate",
- "onSizeExceeded",
- "onError",
- "onExpired"
};
-
-
private volatile InternetResource[] scripts;
@Override
@@ -100,26 +103,41 @@
return true;
}
- private Object createRendererData(FacesContext context, UIQueue queue) {
+ private QueueRendererData createRendererData(FacesContext context, UIQueue queue) {
Map<String, Object> attributes = queue.getAttributes();
- Map<String,Object> data = new HashMap<String, Object>();
+ QueueRendererData data = new QueueRendererData();
- for (String attributeName : PLAIN_ATTRIBUTES) {
+ for (String attributeName : QUEUE_ATTRIBUTES) {
Object value = attributes.get(attributeName);
if (isNotEmpty(value)) {
- data.put(attributeName, value);
+ data.addQueueAttribute(attributeName, value);
}
}
- for (String attributeName : FUNCTION_ATTRIBUTES) {
+ for (String attributeName : REQUEST_ATTRIBUTES) {
Object value = attributes.get(attributeName);
if (isNotEmpty(value)) {
+ data.addRequestAttribute(attributeName, value);
+ }
+ }
+
+ for (String attributeName : QUEUE_FUNCTION_ATTRIBUTES) {
+ Object value = attributes.get(attributeName);
+ if (isNotEmpty(value)) {
//TODO nick - apply proper functions signature
- data.put(attributeName, new
JSFunctionDefinition("event").addToBody(value));
+ data.addQueueAttribute(attributeName, new
JSFunctionDefinition("event").addToBody(value));
}
}
+ for (String attributeName : REQUEST_FUNCTION_ATTRIBUTES) {
+ Object value = attributes.get(attributeName);
+ if (isNotEmpty(value)) {
+ //TODO nick - apply proper functions signature
+ data.addRequestAttribute(attributeName, new
JSFunctionDefinition("event").addToBody(value));
+ }
+ }
+
return data;
}
Added:
trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/QueueRendererData.java
===================================================================
---
trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/QueueRendererData.java
(rev 0)
+++
trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/QueueRendererData.java 2008-11-10
17:06:53 UTC (rev 11070)
@@ -0,0 +1,61 @@
+/**
+ * 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.HashMap;
+import java.util.Map;
+
+/**
+ * @author Denis Morozov
+ * @since 3.3.0
+ */
+public class QueueRendererData {
+
+ private Map<String, Object> queueAttributes;
+
+ private Map<String, Object> requestAttributes;
+
+ public void addQueueAttribute(String key, Object value) {
+ if (queueAttributes == null) {
+ queueAttributes = new HashMap<String, Object>();
+ }
+
+ queueAttributes.put(key, value);
+ }
+
+ public void addRequestAttribute(String key, Object value) {
+ if (requestAttributes == null) {
+ requestAttributes = new HashMap<String, Object>();
+ }
+
+ requestAttributes.put(key, value);
+ }
+
+ public Map<String, Object> getQueueAttributes() {
+ return queueAttributes;
+ }
+
+ public Map<String, Object> getRequestAttributes() {
+ return requestAttributes;
+ }
+}
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-10
17:04:25 UTC (rev 11069)
+++
trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/scripts/QueueScriptResourceRenderer.java 2008-11-10
17:06:53 UTC (rev 11070)
@@ -35,6 +35,8 @@
import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.ajax4jsf.resource.BaseResourceRenderer;
import org.ajax4jsf.resource.InternetResource;
+import org.richfaces.renderkit.html.QueueRegistry;
+import org.richfaces.renderkit.html.QueueRendererData;
/**
* @author Nick Belaevski
@@ -53,7 +55,7 @@
if (requestMap.get(resourceKey) == null) {
requestMap.put(resourceKey, Boolean.TRUE);
- Map<String, Object> queues =
org.richfaces.renderkit.html.QueueRegistry.getRegisteredQueues(context);
+ Map<String, QueueRendererData> queues =
QueueRegistry.getRegisteredQueues(context);
if (queues != null && !queues.isEmpty()) {
super.encode(resource, context, queues, attributes);
@@ -81,12 +83,19 @@
FacesContext context, Object data) throws IOException {
ResponseWriter writer = context.getResponseWriter();
- Map<String, Object> queues = (Map<String, Object>) data;
+ Map<String, QueueRendererData> queues = (Map<String, QueueRendererData>)
data;
- for (Entry<String, Object> entry : queues.entrySet()) {
+ for (Entry<String, QueueRendererData> entry : queues.entrySet()) {
+ String queueName = entry.getKey();
+ QueueRendererData rendererData = entry.getValue();
writer.writeText("A4J.AJAX.EventQueue.addQueue(", null);
- writer.writeText(new JSObject("A4J.AJAX.EventQueue", entry.getKey(),
entry.getValue()).toScript(), null);
+ writer.writeText(
+ new JSObject("A4J.AJAX.EventQueue",
+ queueName,
+ rendererData.getQueueAttributes(),
+ rendererData.getRequestAttributes()
+ ).toScript(), null);
writer.writeText(");", null);
}
Added: trunk/sandbox/ui/queue/src/test/java/org/richfaces/ScriptTest.java
===================================================================
--- trunk/sandbox/ui/queue/src/test/java/org/richfaces/ScriptTest.java
(rev 0)
+++ trunk/sandbox/ui/queue/src/test/java/org/richfaces/ScriptTest.java 2008-11-10 17:06:53
UTC (rev 11070)
@@ -0,0 +1,89 @@
+/**
+ * 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;
+
+import java.util.List;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIForm;
+
+import org.ajax4jsf.component.UIAjaxFunction;
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.richfaces.component.UIQueue;
+
+import com.gargoylesoftware.htmlunit.ScriptResult;
+import com.gargoylesoftware.htmlunit.WebClient;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine;
+
+/**
+ * @author mikalaj
+ *
+ */
+public class ScriptTest extends AbstractAjax4JsfTestCase {
+
+ public ScriptTest(String name) {
+ super(name);
+ }
+
+ @Override
+ protected WebClient createWebClient() {
+ WebClient webClient = super.createWebClient();
+ webClient.setJavaScriptEngine(new JavaScriptEngine(webClient));
+
+ return webClient;
+ }
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+
+ List<UIComponent> viewRootChildren = facesContext.getViewRoot().getChildren();
+
+ viewRootChildren.add(application.createComponent(UIQueue.COMPONENT_TYPE));
+
+ UIComponent form = application.createComponent(UIForm.COMPONENT_TYPE);
+ viewRootChildren.add(form);
+
+ UIAjaxFunction function = (UIAjaxFunction)
application.createComponent(UIAjaxFunction.COMPONENT_TYPE);
+ function.setName("ajaxSubmit");
+ form.getChildren().add(function);
+
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testScript() throws Exception {
+ HtmlPage page = this.renderView();
+ assertNotNull(page);
+
+ ScriptResult scriptResult =
page.executeJavaScript("setTimeout(function(){A4J.AJAX.EventQueue.getOrCreateQueue('"
+
+ UIQueue.GLOBAL_QUEUE_NAME + "')}, 2000000)");
+ System.out.println(scriptResult.getJavaScriptResult());
+
+
+ }
+}