PDA

View Full Version : [CLOSED][3.0rc1] doSend in remotingProvider sends inconsistent type (Array or Object)



crp_spaeth
4 May 2009, 5:46 AM
Hi There,

I am playing around with the new Ext.Direct functionalities and I asked myself why you send different Javascript Types in the doSend Function f the remotingProvider.

I really like the possibility to be able to buffer request and send them all at once after a specific time but if enableBuffer is enabled I think doSend should allways send an encoded Array to Server even if Ext asks the server only to execute one Call....

If I add one Record to the Store Ext will post of this string:

{"action":"TestAction","method":"createData","data":[{"email":"d","first":"d","last":"d"}],"type":"rpc"
,"tid":3}

But if I Add two Records before the buffertime goes by I and up with that post:


[{"action":"TestAction","method":"createData","data":[{"email":"d","first":"d","last":"d"}],"type":"rpc"
,"tid":4},{"action":"TestAction","method":"createData","data":[{"email":"d","first":"d","last":"d"}]
,"type":"rpc","tid":5}]






doSend : function(data){
var o = {
url: this.url,
callback: this.onData,
scope: this
};

// send only needed data
var callData;
if(Ext.isArray(data)){
callData = [];
for(var i = 0, len = data.length; i < len; i++){
callData.push(this.getCallData(data[i]));
}
}else{
callData = this.getCallData(data);
}

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);
},


I think this would be more consistent if you would add some brackets around this.getCallData(data) in the else block:

if(Ext.isArray(data)){
callData = [];
for(var i = 0, len = data.length; i < len; i++){
callData.push(this.getCallData(data[i]));
}
}else{
callData = [ this.getCallData(data) ];
}

crp_spaeth
4 May 2009, 5:58 AM
Maybe it's better to change the combineAndSend Method to


combineAndSend : function(){

if(this.callBuffer.length > 0){
this.doSend(this.callBuffer);
this.callBuffer = [];
}
},

aconran
4 May 2009, 10:19 AM
This is by design. I agree that it may simplify things to have the request always sent as a JSON-encoded array as it would simplify the server-side stack.

We'll consider this suggestion.

crp_spaeth
4 May 2009, 10:28 AM
Okay when this is implemented by design may you can tell me the purpose... I dont see it Yet :(