1. #1
    Ext User
    Join Date
    Jun 2007
    Posts
    11
    Vote Rating
    0
    kilrae is on a distinguished road

      0  

    Default HttpProxy requests abort others in progress

    HttpProxy requests abort others in progress


    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:

    Code:
    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:

    Code:
    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"})

  2. #2
    Sencha User jack.slocum's Avatar
    Join Date
    Mar 2007
    Location
    Tampa, FL
    Posts
    6,955
    Vote Rating
    17
    jack.slocum will become famous soon enough jack.slocum will become famous soon enough

      0  

    Default


    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.
    Jack Slocum
    Ext JS Founder
    Original author of Ext JS 1, 2 & 3.
    Twitter: @jackslocum
    jack@extjs.com

  3. #3
    Ext User schmidetzki's Avatar
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    110
    Vote Rating
    0
    schmidetzki is on a distinguished road

      0  

    Default should be documented

    should be documented


    Quote Originally Posted by jack.slocum View Post
    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.

Thread Participants: 2