Author: dmorozov
Date: 2008-11-16 09:48:05 -0500 (Sun, 16 Nov 2008)
New Revision: 11183
Modified:
trunk/framework/impl/src/main/javascript/ajaxjsf/queue.js
Log:
https://jira.jboss.org/jira/browse/RF-4854 - implementation: queue-size related code
Modified: trunk/framework/impl/src/main/javascript/ajaxjsf/queue.js
===================================================================
--- trunk/framework/impl/src/main/javascript/ajaxjsf/queue.js 2008-11-15 12:35:11 UTC (rev
11182)
+++ trunk/framework/impl/src/main/javascript/ajaxjsf/queue.js 2008-11-16 14:48:05 UTC (rev
11183)
@@ -75,6 +75,10 @@
isEmpty: function() {
return this.getSize() == 0;
+ },
+
+ hasNextItem: function() {
+ return this.items.length != 0;
}
}
}());
@@ -140,43 +144,52 @@
return data;
},
-
- push: function(data) {
- var requestId = data.getRequestId();
-
- if (this.requestId == requestId) {
- this.data = data;
- data.setEventsCounter(++this.eventsCounter);
+
+ push: function() {
+ var DROP_NEW = 'dropNew';
+ var DROP_NEXT = 'dropNext';
+ var FIRE_NEW = 'fireNew';
+ var FIRE_NEXT = 'fireNext';
+
+ return function(data) {
+ var requestId = data.getRequestId();
- this.resetRequestDelay();
- } else {
- if (this.data) {
- this.stopRequestDelay();
- this.pipeline.addEvent(this.pop());
- }
-
- if (this.pipeline.isFull()) {
- //special handling for size = 1 queue
+ if (this.requestId == requestId) {
+ this.data = data;
+ data.setEventsCounter(++this.eventsCounter);
- var behavior = data.queue.getSizeExceededBehavior();
- if (behavior == 'dropNew') {
- return;
- } else if (behavior == 'fireNew') {
- data.submitWithoutCallback();
- return;
- } else if (behavior == 'fireNext') {
- this.pipeline.fireFirst();
- } else if (behavior == 'dropNext') {
- this.pipeline.dropFirst();
+ this.resetRequestDelay();
+ } else {
+ if (this.data) {
+ this.stopRequestDelay();
+ this.pipeline.addEvent(this.pop());
}
-
+
+ if (this.pipeline.isFull()) {
+ var behavior = data.queue.getSizeExceededBehavior();
+ if (behavior == DROP_NEW ||
+ (behavior == DROP_NEXT && !this.pipeline.hasNextItem())) {
+
+ return;
+ } else if (behavior == FIRE_NEW ||
+ (behavior == FIRE_NEXT && !this.pipeline.hasNextItem())) {
+
+ data.submitWithoutCallback();
+ return;
+ } else if (behavior == DROP_NEXT) {
+ this.pipeline.dropFirst();
+ } else if (behavior == FIRE_NEXT) {
+ this.pipeline.fireFirst();
+ }
+
+ }
+
+ this.data = data;
+ this.requestId = requestId;
+ this.startRequestDelay();
}
-
- this.data = data;
- this.requestId = requestId;
- this.startRequestDelay();
}
- }
+ }()
});