1. #1
    Sencha User Gr3yh0und's Avatar
    Join Date
    Aug 2011
    Location
    Germany
    Posts
    10
    Vote Rating
    0
    Gr3yh0und is on a distinguished road

      0  

    Default Answered: Extended Proxy does not load config

    Answered: Extended Proxy does not load config


    Hey,

    I'm just trying to rewrite my hardcoded proxies with a new class. So far i got:

    PHP Code:
        Ext.define('Application.ProxyAjax', {
            
    extend'Ext.data.proxy.Ajax',
            
    alias'widget.teststore',
            
    autoSavetrue,
        
            
    constructor: function() {
                
    this.url 'config/api_mysql.php';
                
    this.api = {
                    
    read:        'config/api_mysql.php?do=read',
                    
    update:     'config/api_mysql.php?do=update',
                    
    create:     'config/api_mysql.php?do=create',
                    
    destroy:     'config/api_mysql.php?do=destroy'
                
    };
                
    this.actionMethods = {
                    
    read:         'POST',
                    
    update:     'POST',
                    
    create:     'POST',
                    
    destroy:     'POST'
                
    };
                
    this.reader = {
                    
    type:             'json',
                    
    model:             'Open',
                    
    root:             'results',
                    
    totalProperty:     'total',
                    
    idProperty:     'id'
                
    };
                
    this.writer = {
                    
    type:         'json',
                    
    model:         'Open',
                    
    root:         'results',
                    
    encode:     'true'
                
    };

                
    this.callParent();
            }
        });
        
        var 
    proxy_open Ext.create('Application.ProxyAjax');
        
    //proxy_open.api.read = 'config/api_mysql.php?do=read'; 
    Now when I check the "api" value with firebug its just nothing in it. It actually also doesn't load anything... when I set the api from outside it is working (as last line up there is showing).

    Any ideas why it isn't working?

  2. The constructor of Ext.data.proxy.Server (= that of Ext.data.proxy.Ajax) sets api to the either config.api or an empty object. So your setting of api gets overwritten. (See: http://docs.sencha.com/ext-js/4-0/so...a-proxy-Server)

    Just change it to:

    Code:
      constructor: function(config) { // note the config!
        config.api = {
          ... // whatever you wanna set
        }
    
        this.callParent([config]); // again, note the config!
      }

  3. #2
    Sencha User
    Join Date
    Dec 2009
    Location
    Enschede, The Netherlands
    Posts
    327
    Answers
    16
    Vote Rating
    13
    flanders will become famous soon enough

      0  

    Default


    The constructor of Ext.data.proxy.Server (= that of Ext.data.proxy.Ajax) sets api to the either config.api or an empty object. So your setting of api gets overwritten. (See: http://docs.sencha.com/ext-js/4-0/so...a-proxy-Server)

    Just change it to:

    Code:
      constructor: function(config) { // note the config!
        config.api = {
          ... // whatever you wanna set
        }
    
        this.callParent([config]); // again, note the config!
      }

  4. #3
    Sencha User
    Join Date
    Dec 2009
    Location
    Enschede, The Netherlands
    Posts
    327
    Answers
    16
    Vote Rating
    13
    flanders will become famous soon enough

      0  

    Default


    IMHO: Avoid using the constructor when possible, but stick to initComponent. But in both cases, the earlier you can do the ancestors constructor/initComponent, the better.

    Do custom stuff later on. (I don't think languages like Java force you to call the parent constructor as the first thing you do )

  5. #4
    Sencha User Gr3yh0und's Avatar
    Join Date
    Aug 2011
    Location
    Germany
    Posts
    10
    Vote Rating
    0
    Gr3yh0und is on a distinguished road

      0  

    Default


    Okay, got it right this was:

    PHP Code:
    Ext.define('Application.ProxyAjax', {
            
    extend'Ext.data.proxy.Ajax',
            
    alias'widget.teststore',
            
            
    config: {
                
    url'config/api_mysql.php',
                
    api: {
                    
    read:        'config/api_mysql.php?do=read',
                    
    update:     'config/api_mysql.php?do=update',
                    
    create:     'config/api_mysql.php?do=create',
                    
    destroy:     'config/api_mysql.php?do=destroy'
                
    }
                  ...
            },
        
            
    constructor: function(config) {    
                
    this.callParent(config);
                
    this.initConfig(config);
            }
        }); 

Thread Participants: 1

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi