PDA

View Full Version : DWRProxy and passing an argument.



bowa
15 Oct 2007, 9:38 AM
I am succesfully using <a href="http://extjs.com/forum/showthread.php?p=21858">DWRProxy</a> (i dont know why its posted in ext 2.0 forum it works perfectly in 1.x too).

But my remote method needs an argument and i don't didn't find a way to pass that along without screwing the whole thing up.

Anyone knows how to change the code so i can pas an argument (or to make it future proof) and array of extra arguments ?

Thanks in advance.

bowa
15 Oct 2007, 11:41 PM
ok i combined some different DWRProxy implementations and came to this result, 'args' is an array of extra arguments, it not needed, just pass []



Ext.data.DWRProxy = function(dwrCall, args){
Ext.data.DWRProxy.superclass.constructor.call(this);
this.dwrCall = dwrCall;
this.args = args;
};

Ext.extend(Ext.data.DWRProxy, Ext.data.DataProxy, {
load : function(params, reader, callback, scope, arg) {
if(this.fireEvent("beforeload", this, params) !== false) {
var delegate = this.loadResponse.createDelegate(this, [reader, callback, scope, arg], 1);
var callParams = new Array();
if(this.args && (this.args.length > 0))
callParams = this.args.slice();
callParams.push(delegate);
this.dwrCall.apply(this, callParams);
} else {
callback.call(scope || this, null, arg, false);
}
},

loadResponse : function(response, reader, callback, scope, arg) {
var result;
try {
result = reader.read(response);
} catch(e) {
this.fireEvent("loadexception", this, null, response, e);
callback.call(scope, null, arg, false);
return;
}
callback.call(scope, result, arg, true);
},

update : function(dataSet){},

updateResponse : function(dataSet)
{}
});