Author: nbelaevski
Date: 2008-11-13 14:51:28 -0500 (Thu, 13 Nov 2008)
New Revision: 11155
Modified:
trunk/sandbox/samples/queue-sample/src/main/java/org/richfaces/Bean.java
trunk/sandbox/samples/queue-sample/src/main/java/org/richfaces/OversizeBean.java
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/sized-queue.xhtml
trunk/sandbox/samples/queue-sample/src/main/webapp/pages/view-queue.xhtml
trunk/sandbox/samples/queue-sample/src/main/webapp/templates/index.xhtml
Log:
Queue sample updated
Modified: trunk/sandbox/samples/queue-sample/src/main/java/org/richfaces/Bean.java
===================================================================
--- trunk/sandbox/samples/queue-sample/src/main/java/org/richfaces/Bean.java 2008-11-13
19:50:57 UTC (rev 11154)
+++ trunk/sandbox/samples/queue-sample/src/main/java/org/richfaces/Bean.java 2008-11-13
19:51:28 UTC (rev 11155)
@@ -23,12 +23,17 @@
import java.util.Map;
+import javax.faces.component.UIComponent;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import org.ajax4jsf.event.AjaxEvent;
import org.ajax4jsf.event.AjaxListener;
+import org.ajax4jsf.javascript.JSFunction;
+import org.ajax4jsf.javascript.JSReference;
+import org.ajax4jsf.javascript.ScriptString;
+import org.ajax4jsf.taglib.html.jsp.AjaxFunction;
/**
* @author $Autor$
@@ -40,6 +45,8 @@
private long clientRequestDelay = 300;
+ private long queueRequestDelay = 0;
+
private boolean pollEnabled;
private static final String AJAX_REQUESTS_COUNT_ATTRIBUTE =
"ajaxRequestsCount";
@@ -60,6 +67,14 @@
this.clientRequestDelay = clientRequestDelay;
}
+ public long getQueueRequestDelay() {
+ return queueRequestDelay;
+ }
+
+ public void setQueueRequestDelay(long queueRequestDelay) {
+ this.queueRequestDelay = queueRequestDelay;
+ }
+
public boolean isPollEnabled() {
return pollEnabled;
}
@@ -107,4 +122,5 @@
sessionMap.put(AJAX_REQUESTS_COUNT_ATTRIBUTE, ++count);
}
+
}
\ No newline at end of file
Modified:
trunk/sandbox/samples/queue-sample/src/main/java/org/richfaces/OversizeBean.java
===================================================================
---
trunk/sandbox/samples/queue-sample/src/main/java/org/richfaces/OversizeBean.java 2008-11-13
19:50:57 UTC (rev 11154)
+++
trunk/sandbox/samples/queue-sample/src/main/java/org/richfaces/OversizeBean.java 2008-11-13
19:51:28 UTC (rev 11155)
@@ -24,6 +24,7 @@
import java.util.HashMap;
import java.util.Map;
+import javax.faces.FacesException;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
@@ -44,6 +45,14 @@
this.queueData = new HashMap<String, String>();
}
+ public void fireDelay() {
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException e) {
+ throw new FacesException(e);
+ }
+ }
+
public void action() {
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
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-13
19:50:57 UTC (rev 11154)
+++ trunk/sandbox/samples/queue-sample/src/main/webapp/pages/form-queue.xhtml 2008-11-13
19:51:28 UTC (rev 11155)
@@ -31,7 +31,7 @@
</ui:define>
<ui:define name="formQueue">
- <q:queue requestDelay="1000" />
+ <q:queue requestDelay="#{bean.queueRequestDelay}" />
</ui:define>
<ui:define name="title">Global form queue</ui:define>
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-13
19:50:57 UTC (rev 11154)
+++ trunk/sandbox/samples/queue-sample/src/main/webapp/pages/index.xhtml 2008-11-13
19:51:28 UTC (rev 11155)
@@ -28,11 +28,11 @@
<ui:decorate template="/templates/index.xhtml">
<ui:define name="viewQueue">
- <q:queue name="queue" requestDelay="1000"
oncomplete="window.status = 'queue handler'"/>
+ <q:queue name="queue"
requestDelay="#{bean.queueRequestDelay}" oncomplete="window.status =
'queue handler'"/>
</ui:define>
<ui:define name="formQueue">
- <q:queue name="formQueue" requestDelay="1000" />
+ <q:queue name="formQueue"
requestDelay="#{bean.queueRequestDelay}" />
</ui:define>
<ui:define name="title">No global queues</ui:define>
Modified: trunk/sandbox/samples/queue-sample/src/main/webapp/pages/sized-queue.xhtml
===================================================================
--- trunk/sandbox/samples/queue-sample/src/main/webapp/pages/sized-queue.xhtml 2008-11-13
19:50:57 UTC (rev 11154)
+++ trunk/sandbox/samples/queue-sample/src/main/webapp/pages/sized-queue.xhtml 2008-11-13
19:51:28 UTC (rev 11155)
@@ -27,8 +27,8 @@
<a4j:status startText="...running..." stopText="stopped"
startStyle="color: green" />
- <c:set var="size" value="1" />
- <c:set var="requestDelay" value="1500" />
+ <c:set var="size" value="2" />
+ <c:set var="requestDelay" value="#{bean.queueRequestDelay}"
/>
<c:forEach items="#{oversizeBean.queueNames}"
var="queueName">
<q:queue requestDelay="#{requestDelay}" size="#{size}"
name="#{queueName}"
@@ -69,9 +69,13 @@
<h:form>
<c:forEach items="#{oversizeBean.queueNames}"
var="queueName">
- <button onclick="#{queueName}Fire1();#{queueName}Fire2(); return
false;">
+ <button
onclick="#{queueName}FireDelay();#{queueName}Fire1();#{queueName}Fire2(); return
false;">
#{queueName}
</button>
+ <a4j:jsFunction action="#{oversizeBean.fireDelay}"
+ name="#{queueName}FireDelay"
+ reRender="queueStatus" eventsQueue="#{queueName}">
+ </a4j:jsFunction>
<c:forEach begin="1" end="2" var="index">
<a4j:jsFunction action="#{oversizeBean.action}"
name="#{queueName}Fire#{index}"
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-13
19:50:57 UTC (rev 11154)
+++ trunk/sandbox/samples/queue-sample/src/main/webapp/pages/view-queue.xhtml 2008-11-13
19:51:28 UTC (rev 11155)
@@ -28,7 +28,7 @@
<ui:decorate template="/templates/index.xhtml">
<ui:define name="viewQueue">
- <q:queue requestDelay="1000" oncomplete="window.status =
'queue handler'"/>
+ <q:queue requestDelay="#{bean.queueRequestDelay}"
oncomplete="window.status = 'queue handler'"/>
</ui:define>
<ui:define name="formQueue">
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-13
19:50:57 UTC (rev 11154)
+++ trunk/sandbox/samples/queue-sample/src/main/webapp/templates/index.xhtml 2008-11-13
19:51:28 UTC (rev 11155)
@@ -6,7 +6,6 @@
xmlns:q="http://labs.jboss.com/jbossrichfaces/ui/ui/queue">
<ui:composition>
-
<h2><ui:insert name="title" /></h2>
<ui:insert name="viewQueue" />
@@ -20,11 +19,18 @@
 
- <a4j:commandLink value="Reset ajax counter"
action="#{bean.resetAjaxCounter}" onclick="hideLog()"
oncomplete="LOG.clear();showLog();"/>
+ <a4j:commandLink eventsQueue="resetCounterQueue" value="Reset ajax
counter" action="#{bean.resetAjaxCounter}" onclick="hideLog()"
oncomplete="LOG.clear();showLog();"/>
<br /><br />
<fieldset>
+ <h:outputLabel for="queueRequestDelay" value="Queue request delay
" />
+ <h:inputText id="queueRequestDelay"
value="#{bean.queueRequestDelay}">
+ <f:convertNumber />
+ </h:inputText>
+
+ <br />
+
<h:outputLabel for="clientRequestDelay" value="Client request delay
" />
<h:inputText id="clientRequestDelay"
value="#{bean.clientRequestDelay}">
<f:convertNumber />