Author: pyaschenko
Date: 2010-05-06 11:21:35 -0400 (Thu, 06 May 2010)
New Revision: 16909
Modified:
root/framework/trunk/impl/src/main/resources/META-INF/resources/richfaces-queue.js
root/framework/trunk/impl/src/test/resources/javascript/richfaces-jsf-ajax-qunit.js
root/framework/trunk/impl/src/test/resources/javascript/richfaces-queue-qunit-request.js
Log:
https://jira.jboss.org/jira/browse/RF-7893
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-06
10:57:11 UTC (rev 16908)
+++
root/framework/trunk/impl/src/main/resources/META-INF/resources/richfaces-queue.js 2010-05-06
15:21:35 UTC (rev 16909)
@@ -81,19 +81,23 @@
}
}
if (id) {
- this.queueOptions = defaultQueueOptions[id];
+ this.queueOptions = defaultQueueOptions[id] || {};
+ if (this.queueOptions.queueId) {
+ this.queueOptions = $.extend({},
(defaultQueueOptions[this.queueOptions.queueId]||{}), this.queueOptions);
+ }
+
}
this.event = event;
//similarityGroupingId is mutable, thus we need special field for it
- this.similarityGroupingId = this.options.similarityGroupingId;
+ this.similarityGroupingId = (typeof this.options.similarityGroupingId !=
"undefined") ? this.options.similarityGroupingId :
this.queueOptions.similarityGroupingId;
this.eventsCount = 1;
};
$.extend(QueueEntry.prototype, {
// now unused functions: isIgnoreDupResponses, ondrop, clearEntry
isIgnoreDupResponses: function() {
- return this.options.ignoreDupResponses;
+ return (typeof this.options.ignoreDupResponses != "undefined") ?
this.options.ignoreDupResponses : this.queueOptions.ignoreDupResponses;
},
getSimilarityGroupingId: function() {
@@ -254,9 +258,14 @@
// what is a context should be??
handler.call(null, entry);
}
+ handler = entry.queueOptions[handlerName];
+ if (handler) {
+ // the same about context
+ handler.call(null, entry);
+ }
var opts, handler2;
- if (entry.options.queueId &&
- (opts=defaultQueueOptions[entry.options.queueId]) &&
+ if (entry.queueOptions.queueId &&
+ (opts=defaultQueueOptions[entry.queueOptions.queueId]) &&
(handler2=opts[handlerName])
&& handler2!=handler) {
// the same about context
Modified:
root/framework/trunk/impl/src/test/resources/javascript/richfaces-jsf-ajax-qunit.js
===================================================================
---
root/framework/trunk/impl/src/test/resources/javascript/richfaces-jsf-ajax-qunit.js 2010-05-06
10:57:11 UTC (rev 16908)
+++
root/framework/trunk/impl/src/test/resources/javascript/richfaces-jsf-ajax-qunit.js 2010-05-06
15:21:35 UTC (rev 16909)
@@ -12,6 +12,7 @@
jsf.ajax.eventHandlers.push(handler);
},
addOnError: function (handler) {
+ jsf.ajax.errorHandlers.push(handler);
}
}
})();
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-06
10:57:11 UTC (rev 16908)
+++
root/framework/trunk/impl/src/test/resources/javascript/richfaces-queue-qunit-request.js 2010-05-06
15:21:35 UTC (rev 16909)
@@ -5,6 +5,8 @@
var event = {type:"testevent"};
var options = {requestDelay:1000, param:"value"};
+ var body = document.getElementsByTagName("body")[0];
+
// reference to original jsf.ajax.request function
test("Reference to origional jsf.ajax.request function", function() {
expect(1);
@@ -22,7 +24,41 @@
expect(1);
equals(RichFaces.queue.setQueueOptions(), RichFaces.queue);
});
+
+ // queue handlers
+ test("queue event and error handlers", function() {
+ expect(4);
+ equals(jsf.ajax.eventHandlers.length, 1, "one event handler");
+ equals(typeof jsf.ajax.eventHandlers[0], "function", "event handler is
function");
+ equals(jsf.ajax.errorHandlers.length, 1, "one error handler");
+ equals(typeof jsf.ajax.errorHandlers[0], "function", "error handler is
function");
+ });
//TODO: add request test here
//jsf.ajax.request
+ test("jsf.ajax.request - ", function() {
+ expect(2);
+
+ RichFaces.ajax.jsfRequest = function (source, event, options) {
+ for (var i=0; i<jsf.ajax.eventHandlers.length;i++) {
+ jsf.ajax.eventHandlers[i]({type:"event", status:"success"});
+ }
+ equals(source.id, "testButton1", "source");
+ equals(event.type, "click", "event");
+ equals(options['AJAX:EVENTS_COUNT'], 1,
"options['AJAX:EVENTS_COUNT']");
+ equals(typeof options.parameters, "object",
"options.parameters");
+ equals(options.parameters.key, "value",
"options.parameters.key");
+ }
+
+ var elements = RichFaces.QUnit.appendDomElements(body,
+ '<form id="testForm">'+
+ '<input id="testButton1" type="button"
value="hello"
onclick="jsf.ajax.request(this,event,{parameters:{key:\'value\'}})"/>'+
+ '<input id="testButton2" type="button"
value="hello" onclick="jsf.ajax.request()"/>'+
+ '</table>'+
+ '</form>');
+
+ document.getElementById("testButton1").click({type:"onclick"});
+ expect(5);
+ //equals(RichFaces.queue.setQueueOptions(), RichFaces.queue);
+ });
});
\ No newline at end of file