Author: nbelaevski
Date: 2009-12-03 08:19:01 -0500 (Thu, 03 Dec 2009)
New Revision: 16052
Modified:
root/framework/trunk/impl/src/main/resources/META-INF/resources/richfaces-queue.js
Log:
Results of code review for queue commit
Modified:
root/framework/trunk/impl/src/main/resources/META-INF/resources/richfaces-queue.js
===================================================================
---
root/framework/trunk/impl/src/main/resources/META-INF/resources/richfaces-queue.js 2009-12-03
12:07:35 UTC (rev 16051)
+++
root/framework/trunk/impl/src/main/resources/META-INF/resources/richfaces-queue.js 2009-12-03
13:19:01 UTC (rev 16052)
@@ -13,15 +13,18 @@
richfaces.queue = function(opts){
+ //TODO: naming - class should be called QueueEntry, and first argument is
"source", not query
var queueEntry = function(query, event, options) {
this.query = query;
this.options = options || {};
this.event = event;
-
+
+ //similarityGroupingId is mutable, thus we need special field for it
this.similarityGroupingId = this.options.similarityGroupingId;
this.eventsCount = 1;
};
+ //TODO: fix bad indentation of code
jQuery.extend(queueEntry.prototype, {
isIgnoreDupResponses: function() {
@@ -45,6 +48,7 @@
onRequestDelayPassed: function() {
this.readyToSubmit = true;
+ //TODO: should be this.queue.submitFirst
submitFirst();
},
@@ -94,20 +98,26 @@
});
// TODO: add this two variables to richfaces and report bug to jsf about constants
+ //TODO: what's the point in such kind of hash?
var jsfDataTypes = {'event' : 'event'};
var jsfEventNames = {'success' : 'success'};
var log = richfaces.log;
var items = [];
var queueOptions = opts || {};
+ //TODO: that's not last, but first
var last;
+ //TODO: inline this variable
var queueMode = queueOptions.mode;
+ //TODO: inline this variable
var queueRequestDelay = queueOptions.requestDelay;
+ //TODO: instance of this function will be created for each queue
var onError = function (data) {
log.debug("richfaces.queue: ajax submit error");
last = null;
+ //TODO: what if somebody is going to clear queue on error?
submitFirst();
};
@@ -133,10 +143,14 @@
}
if (items[0].readyToSubmit) {
last = items.shift();
+ //TODO: unnecessary check
if (last.readyToSubmit) {
log.debug("richfaces.queue: will submit request NOW");
+ //TODO: events counter should be submitted
//last.query.appendParameter("AJAX:EVENTS_COUNT", last.eventsCount);
var params = richfaces.processRequestParams(last.query, last.options);
+ //TODO: jsf.ajax.request should be used
+ //TODO: copy of event should be created otherwise IE will fail
richfaces.ajax.request(last.query, last.event, params);
if (last.options.queueonsubmit) {
last.options.queueonsubmit.call(last);
@@ -187,7 +201,9 @@
log.debug("Last queue entry is not the last anymore. Stopping requestDelay
timer and marking entry as ready for submission")
lastEntry.stopTimer();
+ //TODO: create method resetSimilarityGroupingId()
lastEntry.setSimilarityGroupingId(undefined);
+ //TODO: create method setReadyToSubmit()
lastEntry.readyToSubmit = true;
items.push(entry);
@@ -202,6 +218,7 @@
},
+ //TODO: remove empty functions
pop: function () {
},
Show replies by date