Author: pyaschenko
Date: 2010-05-05 10:32:59 -0400 (Wed, 05 May 2010)
New Revision: 16895
Modified:
root/framework/trunk/impl/src/main/resources/META-INF/resources/richfaces-queue.js
root/framework/trunk/impl/src/test/resources/javascript/richfaces-queue-qunit-request.js
Log:
queue changes
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 2010-05-05
09:47:34 UTC (rev 16894)
+++
root/framework/trunk/impl/src/main/resources/META-INF/resources/richfaces-queue.js 2010-05-05
14:32:59 UTC (rev 16895)
@@ -17,10 +17,10 @@
* JSF 2.0 original method that sends an asynchronous ajax request to the server
* see jsf.ajax.request method for parameter's description
* @function
- * @name RichFaces.ajax.request
+ * @name RichFaces.ajax.jsfRequest
*
* */
- richfaces.ajax.request = jsf.ajax.request;
+ richfaces.ajax.jsfRequest = jsf.ajax.request;
/**
* RichFaces wrapper function of JSF 2.0 original method jsf.ajax.request
@@ -32,7 +32,6 @@
* @param {object} [options] - The set name/value pairs that can be sent as request
parameters to control client and/or server side request processing
* */
jsf.ajax.request = function request(source, event, options) {
- //richfaces.ajax.request(source, event, options);
richfaces.queue.push(source, event, options);
};
@@ -52,6 +51,7 @@
var defaultQueueOptions = {};
defaultQueueOptions[DEFAULT_QUEUE_ID] = {requestDelay:0, ignoreDupResponse:false,
timeout:0};
+ var eventHandlers = {};
var QueueEntry = function(queue, source, event, options) {
this.queue = queue;
@@ -176,10 +176,10 @@
});
// 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 JSF_EVENT_TYPE = 'event';
+ var JSF_EVENT_SUCCESS = 'success';
+ var JSF_EVENT_COMPLETE = 'complete';
+
var log = richfaces.log;
var items = [];
var lastRequestedEntry;
@@ -193,7 +193,7 @@
};
var onComplete = function (data) {
- if (jsfDataTypes[data.type]=='event' &&
jsfEventNames[data.status]=='success') {
+ if (data.type == JSF_EVENT_TYPE && data.status == JSF_EVENT_SUCCESS) { // or
JSF_EVENT_COMPLETE will be rather
log.debug("richfaces.queue: ajax submit successfull");
lastRequestedEntry = null;
submitFirst();
@@ -215,11 +215,12 @@
if (items[0].getReadyToSubmit()) {
lastRequestedEntry = items.shift();
log.debug("richfaces.queue: will submit request NOW");
- //TODO: copy of event should be created otherwise IE will fail
var o = lastRequestedEntry.options;
+ // copy of event should be created otherwise IE will fail
+ var e = $.extend({}, lastRequestedEntry.event);
//lastRequestedEntry.source.appendParameter("AJAX:EVENTS_COUNT",
lastRequestedEntry.eventsCount);
o["AJAX:EVENTS_COUNT"] = lastRequestedEntry.eventsCount;
- richfaces.ajax.request(lastRequestedEntry.source, lastRequestedEntry.event, o);
+ richfaces.ajax.jsfRequest(lastRequestedEntry.source, e, o);
if (o.queueonsubmit) {
o.queueonsubmit.call(lastRequestedEntry);
}
@@ -244,7 +245,11 @@
};
return {
-
+ /**
+ * @constant
+ * @name RichFaces.queue.DEFAULT_QUEUE_ID
+ * @type string
+ * */
DEFAULT_QUEUE_ID: DEFAULT_QUEUE_ID,
/**
@@ -329,7 +334,6 @@
* @name RichFaces.queue.clear
* */
clear: function () {
- //TODO: clear queue
var lastEntry = getLastEntry();
if (lastEntry) {
lastEntry.stopTimer();
Modified:
root/framework/trunk/impl/src/test/resources/javascript/richfaces-queue-qunit-request.js
===================================================================
---
root/framework/trunk/impl/src/test/resources/javascript/richfaces-queue-qunit-request.js 2010-05-05
09:47:34 UTC (rev 16894)
+++
root/framework/trunk/impl/src/test/resources/javascript/richfaces-queue-qunit-request.js 2010-05-05
14:32:59 UTC (rev 16895)
@@ -8,12 +8,21 @@
// reference to original jsf.ajax.request function
test("Reference to origional jsf.ajax.request function", function() {
expect(1);
- equals(RichFaces.ajax.request, jsf_ajax_request);
+ equals(RichFaces.ajax.jsfRequest, jsf_ajax_request);
});
- //TODO: add setQueueOptions here
+ // default queue id
+ test("Default queue id", function() {
+ expect(1);
+ equals(RichFaces.queue.DEFAULT_QUEUE_ID, "org.richfaces.queue.global");
+ });
+
+ // setQueueOptions
+ test("setQueueOptions chain", function() {
+ expect(1);
+ equals(RichFaces.queue.setQueueOptions(), RichFaces.queue);
+ });
-
//TODO: add request test here
-
+ //jsf.ajax.request
});
\ No newline at end of file