View Full Version : Need a brief explanation on how DWR proxy works

5 Nov 2007, 7:04 PM
I have the dwr proxy up and running which populates a grid. However, what I am unsure about is when the results from the DWR call end up in the grid.

I have some code that looks like the following:
initDataSource(); // line 1
ds.load(); // line 2
buildGrid(); // line 3

The call to dwr is actually made at line 2. However, this could take several seconds as it has to go over the internet. Before the dwr call returns the data line 3 has already executed and the datastore object it is using would be empty.

Can someone explain this to me please:?
Also what is the scope variable and how does it work?
And finally, where does the implementation of the callback method come from? Is that managed by ext?

Below is my dwr proxy.
Ext.data.DWRProxy = function(dwrCall){
Ext.data.DWRProxy.superclass.constructor.call(this );
this.dwrCall = dwrCall;

Ext.extend(Ext.data.DWRAuthorProxy, 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(arg.arg) {
callParams = arg.arg.slice();
this.dwrCall.apply(this, callParams);
} else {
callback.call(scope || this, null, arg, false);

loadResponse : function(data, arrayreader, callback, scope, arg) {
var result;
try {
result = arrayreader.readRecords(data);
} catch(e) {
alert('error: ' + e);
this.fireEvent("loadexception", this, null, response, e);
callback.call(scope, null, arg, false);
callback.call(scope, result, arg, true);

update : function(dataSet){},

updateResponse : function(dataSet)