PDA

View Full Version : HttpProxy requests abort others in progress



kilrae
7 Jul 2007, 10:47 AM
I have two combo boxes that load their contents via an HTTPProxy.

If the HttpProxy is given a Connection config object literal and the first request has not finished before the second one begins, the first request is aborted. If I pass Connection objects rather than configs, it works fine.

HttpProxy.load in HttpProxy.js contains this:


if(this.useAjax){
Ext.applyIf(o, this.conn);
if(this.activeRequest){
Ext.Ajax.abort(this.activeRequest);
}
this.activeRequest = Ext.Ajax.request(o);
}else{
this.conn.request(o);
}


Using a connection object skips the activeRequest check. Perhaps this is a scope issue. The two HttpProxies are separate objects, so it shouldn't happen but it does. This is the code I am using that doesn't work:


var lawyerDS = new Ext.data.Store({
"proxy": new Ext.data.HttpProxy({"url": "/control/lawyer-list", "method": "GET" }),
"reader": new Ext.data.JsonReader({
"root": "records",
"totalProperty": "totalCount",
"id": "id"
}, [{"name": "id"},{"name": "Name"}]),
"baseParams": {"fields": Ext.util.JSON.encode(["id","Name"])}
});
lawyerDS.load();

var courtDS = new Ext.data.Store({
"proxy": new Ext.data.HttpProxy({"url": "/control/court-list", "method": "GET" }),
"reader": new Ext.data.JsonReader({
"root": "records",
"totalProperty": "totalCount",
"id": "id"
}, [{"name": "id"},{"name": "shortname"}])
});
courtDS.load();

It works if one of the HttpProxies is passed something like new Ext.data.Connection({"url": "control/lawyer-list"})

jack.slocum
7 Jul 2007, 1:52 PM
If you don't want it to abort and you are sharing a single HTTPProxy, you will need to define separate connections. Personally, I would recommend defining different Proxies.

schmidetzki
8 Jul 2007, 12:49 AM
Personally, I would recommend defining different Proxies.

I had the same problem and it took me some time to find out what happens.
Even if you create two (or more) HttpProxy-s using "new HttpProxy" each of them use the same connection object ... and the last request cancels the one before.
In a real application this leads to strange behaivier and its hard to find out, why "sometimes" (depending on the timing of the application) a Store is not updated.

To avoid such problems I now create every proxy objects using new HttpProxy(new Ext.Data.Connection).

I think this behaviour of HttpProxy should be better documented. It is very important to know this.