Author: konstantin.mishin
Date: 2011-01-19 12:36:55 -0500 (Wed, 19 Jan 2011)
New Revision: 21090
Added:
trunk/examples/core-demo/src/main/java/org/richfaces/demo/QueueBean.java
Modified:
trunk/core/impl/src/main/resources/META-INF/resources/richfaces-queue.js
trunk/examples/core-demo/src/main/webapp/queue.xhtml
Log:
RF-9289
Modified: trunk/core/impl/src/main/resources/META-INF/resources/richfaces-queue.js
===================================================================
--- trunk/core/impl/src/main/resources/META-INF/resources/richfaces-queue.js 2011-01-19
17:33:54 UTC (rev 21089)
+++ trunk/core/impl/src/main/resources/META-INF/resources/richfaces-queue.js 2011-01-19
17:36:55 UTC (rev 21090)
@@ -34,7 +34,13 @@
jsf.ajax.request = function request(source, event, options) {
richfaces.queue.push(source, event, options);
};
+
+ richfaces.ajax.jsfResponse = jsf.ajax.response;
+ jsf.ajax.response = function request(request, context) {
+ richfaces.queue.response(request, context);
+ };
+
var QUEUE_MODE_PULL = 'pull';
var QUEUE_MODE_PUSH = 'push';
var QUEUE_MODE = QUEUE_MODE_PULL;
@@ -119,7 +125,7 @@
};
$.extend(QueueEntry.prototype, {
- // now unused functions: isIgnoreDupResponses, ondrop, clearEntry
+ // now unused functions: ondrop, clearEntry
isIgnoreDupResponses: function() {
return this.queueOptions.ignoreDupResponses;
},
@@ -381,6 +387,16 @@
},
+ response: function (request, context) {
+ var lastEntry = getLastEntry();
+ if (!lastEntry || !lastRequestedEntry.isIgnoreDupResponses() ||
lastRequestedEntry.getRequestGroupId() != lastEntry.getRequestGroupId()) {
+ richfaces.ajax.jsfResponse(request, context);
+ } else {
+ lastRequestedEntry = null;
+ submitFirstEntry();
+ }
+ },
+
/**
* Remove all QueueEntry from the queue
* @function
Added: trunk/examples/core-demo/src/main/java/org/richfaces/demo/QueueBean.java
===================================================================
--- trunk/examples/core-demo/src/main/java/org/richfaces/demo/QueueBean.java
(rev 0)
+++ trunk/examples/core-demo/src/main/java/org/richfaces/demo/QueueBean.java 2011-01-19
17:36:55 UTC (rev 21090)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.demo;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.SessionScoped;
+
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+@ManagedBean
+@SessionScoped
+public class QueueBean {
+
+ private int counter;
+
+ public void increment() throws InterruptedException {
+ Thread.sleep(2000);
+ counter++;
+ }
+
+ public void reset() {
+ counter = 0;
+ }
+
+ public int getCounter() {
+ return counter;
+ }
+}
Modified: trunk/examples/core-demo/src/main/webapp/queue.xhtml
===================================================================
--- trunk/examples/core-demo/src/main/webapp/queue.xhtml 2011-01-19 17:33:54 UTC (rev
21089)
+++ trunk/examples/core-demo/src/main/webapp/queue.xhtml 2011-01-19 17:36:55 UTC (rev
21090)
@@ -9,10 +9,14 @@
<h:head>
</h:head>
<h:body>
- <a4j:queue />
-
+ <a4j:queue ignoreDupResponses="true"/>
<h:form>
- <h:commandLink value="Common link" />
+ <a4j:commandLink value="Increment"
action="#{queueBean.increment}" render="out"/>
+ <br />
+ <a4j:commandLink value="Reset" action="#{queueBean.reset}"
render="out" />
+ <br />
+ <h:outputText value="Counter:" />
+ <h:outputText id="out" value="#{queueBean.counter}"/>
</h:form>
</h:body>
</f:view>