PDA

View Full Version : Ext.Direct too bugs



cole_yang
26 May 2009, 5:47 PM
I try Ext.Direct,but find has too bugs.

1.


Ext.Direct.removeProvider = function(id) {
//bug forget use this.provider
var provider = id.id ? id : this.providers[id];
if (provider) {
provider.un('data', this.onProviderData, this);
provider.un('exception', this.onProviderException, this);
delete this.providers[provider.id];
provider.disconnect();
}

return provider;
};

2. Ext.direct.RemotingProvider
when form fail,retry use doSend not doForm?
when call fail,can't retry

I fix these problemes:
queueTransaction : function(t) {
//bug for support retry form fail
if (t.form) {
Ext.Ajax.request(t.form);
return;
}

this.callBuffer.push(t);
if (this.enableBuffer) {
if (!this.callTask) {
this.callTask = new Ext.util.DelayedTask(this.combineAndSend,
this);
}
this.callTask.delay(typeof this.enableBuffer == 'number'
? this.enableBuffer
: 10);
} else {
this.combineAndSend();
}
}

doForm : function(c, m, form, callback, scope) {
var t = new Ext.Direct.Transaction({
provider : this,
action : c,
method : m.name,
args : [form, callback, scope],
cb : scope && typeof callback == 'function' ? callback
.createDelegate(scope) : callback
});

if (this.fireEvent('beforecall', this, t) !== false) {
Ext.Direct.addTransaction(t);

form = Ext.getDom(form);
var isUpload = String(form.getAttribute("enctype")).toLowerCase() == 'multipart/form-data';

var params = {
extTID : t.tid,
extAction : c,
extMethod : m.name,
extUpload : String(isUpload)
};
if (callback && typeof callback == 'object') {
Ext.apply(params, callback.params);
}

t.form = {
url : this.url,
params : params,
callback : this.onData,
scope : this,
form : form, //bug add this property,for support retry
isUpload : isUpload,
ts : t
};
Ext.Ajax.request(t.form);
}
}




doSend : function(data) {
//bug add ts,for form and call the same,support retry
var ts = [];
var o = {
url : this.url,
callback : this.onData,
scope : this,
ts : ts
};

// send only needed data
var callData;
if (Ext.isArray(data)) {
callData = [];
for (var i = 0, len = data.length; i < len; i++) {
var d = this.getCallData(data[i]);
callData.push(d);
//bug add these
ts[i] = {
tid : d.tid
};

}
} else {
callData = this.getCallData(data);
ts[0]={tid : callData.tid};
}

if (this.enableUrlEncode) {
var params = {};
params[typeof this.enableUrlEncode == 'string'
? this.enableUrlEncode
: 'data'] = Ext.encode(callData);
o.params = params;
} else {
o.jsonData = callData;
}
Ext.Ajax.request(o);
}