PDA

View Full Version : [FIXED-81] (0.85) Ext.data.Connection.onComplete



watrboy00
16 Jun 2010, 8:37 AM
Seems there are a couple things missing from the data connection core re-write...highlighted them in red.


// private
onComplete : function(r) {
var status = r.xhr.status,
options = r.options,
response, success = true;

if (status >= 200 && status < 300) {
response = this.createResponse(r);
this.fireEvent('requestcomplete', this, response, options);
if (options.success) {
if (!options.scope) {
options.success(response, options);
}
else {
options.success.call(options.scope, response, options);
}
}
}
else {
success = false;
switch (status) {
case 12002:
case 12029:
case 12030:
case 12031:
case 12152:
case 13030:
response = this.createException(r);
default:
response = this.createResponse(r);
}
this.fireEvent('requestexception', this, response, options);
if (options.failure) {
if (!options.scope) {
options.failure(response, options);
}
else {
options.failure.call(options.scope, response, options);
}
}
}

if (options.callback) {
if (!options.scope) {
options.callback(response, options, success); // CHANGED THE ARGUMENT ORDER TO BE CONSISTENT WITH SUCCESS/FAILURE
}
else {
options.callback.call(options.scope, response, options, success); // CHANGED THE ARGUMENT ORDER TO BE CONSISTENT WITH SUCCESS/FAILURE
}
}

delete this.requests[r.id];
}

durlabh
17 Jun 2010, 1:12 PM
I had slightly modified the sequence so that AjaxProxy works and it works as per documentation.



Ext.data.Connection.override({
onComplete: function(r) {
var status = r.xhr.status,
options = r.options,
response, success;

if (status >= 200 && status < 300) {
success = true;
response = this.createResponse(r);
this.fireEvent('requestcomplete', this, response, options);
if (options.success) {
if (!options.scope) {
options.success(response, options);
}
else {
options.success.call(options.scope, response, options);
}
}
}
else {
success = false;
switch (status) {
case 12002:
case 12029:
case 12030:
case 12031:
case 12152:
case 13030:
response = this.createException(r);
break;
default:
response = this.createResponse(r);
}
this.fireEvent('requestexception', this, response, options);
if (options.failure) {
if (!options.scope) {
options.failure(response, options);
}
else {
options.failure.call(options.scope, response, options);
}
}
}

if (options.callback) {
if (!options.scope) {
options.callback(options, success, response);
}
else {
options.callback.call(options.scope, options, success, response);
}
}

delete this.requests[r.id];
}
});

TommyMaintz
17 Jun 2010, 5:11 PM
Thanks guys.

I'll make sure this gets into the library.

watrboy00
22 Jun 2010, 12:50 PM
Thanks for the additional comments durlabh. I noticed this as well after I posted the report but forgot to actually add it back in. I've updated the first post.

TommyMaintz
22 Jun 2010, 2:42 PM
I have added this to git. This will be in the next release. Thanks for the help.