1. #1
    Sencha User omar.belkhodja's Avatar
    Join Date
    Sep 2007
    Location
    Tunisia
    Posts
    32
    Vote Rating
    0
    omar.belkhodja is on a distinguished road

      0  

    Default Class extension doesn't take into account some property initialisation

    Class extension doesn't take into account some property initialisation


    Hello,

    I've created the following class
    Code:
    Application.LoginPanel = Ext.extend(Ext.FormPanel, {
         border:false
        
    	,initComponent:function() {
            Ext.apply(this, {
    		
    	        labelWidth: 70, 
    	        url:'html/login.php',
    	        frame:true,
    	        title: 'Enregistrement',
    	        bodyStyle:'padding:5px 5px 0',
    	        width: 200,
    			height:130,
    	        defaults: {width: 100},
    	        defaultType: 'textfield',
    	
    	        items: [{
    	            fieldLabel: 'Username',
    	            name: 'user'
    	        },{
    	            fieldLabel: 'Password',
    	            name: 'password'
    	        }]
    	
    
        	});
     
        	Application.LoginPanel.superclass.initComponent.apply(this, arguments);
    	} // fin de la fonction initComponent
     
        ,onRender:function() {
            //this.store.load();
     
            Application.LoginPanel.superclass.onRender.apply(this, arguments);
        } // fin de la fonction onRender
    });
    I was expecting that when I will instanciate an object and call the GetForm().submit() method it will be suffisant (something like this)

    Code:
    var myLogin = new Application.LoginPanel();
    myLogin.GetForm().submit();
    But this creates an error, and I've seen that the error doesn't happen if I use the following code :

    Code:
    var myLogin = new Application.LoginPanel({url:'html/login.php'});
    myLogin.GetForm().submit();
    So for me it is obvious that the url property has not been initialised, or have been rewriten after calling the Ext.Apply method.

    I believe that I am using the pattern suggested somewhere in the ExtJS example for extending classes, so is this a bug or did I misunderstood something ?

    Thanks
    You have to know before dreaming !

  2. #2
    Ext User
    Join Date
    Jul 2007
    Location
    Florida
    Posts
    9,996
    Vote Rating
    5
    mjlecomte will become famous soon enough mjlecomte will become famous soon enough

      0  

    Default


    I think you have the same problem as I had, see this thread, first and currently last post:
    http://extjs.com/forum/showthread.php?t=28085

  3. #3
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,823
    Vote Rating
    608
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    It's because the url config is really for the underlying basic form.

    If you have a look at the source, you'll see that this is created using the initialConfig.

    Code:
    ,initComponent:function() {
            this.initialConfig.url = 'html/login.php';
            Ext.apply(this, {
    		
    	        labelWidth: 70, 
    	        frame:true,
    	        title: 'Enregistrement',
    	        bodyStyle:'padding:5px 5px 0',
    	        width: 200,
    			height:130,
    	        defaults: {width: 100},
    	        defaultType: 'textfield',
    	
    	        items: [{
    	            fieldLabel: 'Username',
    	            name: 'user'
    	        },{
    	            fieldLabel: 'Password',
    	            name: 'password'
    	        }]
    	
    
        	});
     
        	Application.LoginPanel.superclass.initComponent.apply(this, arguments);
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  4. #4
    Sencha User omar.belkhodja's Avatar
    Join Date
    Sep 2007
    Location
    Tunisia
    Posts
    32
    Vote Rating
    0
    omar.belkhodja is on a distinguished road

      0  

    Default


    Thank you guys. Now I have the solution from your posts. I just need to understand when we have to use the Ext.Apply and when do we just need to set directly the property (I've not yet seen the tutorial, I hope I will find the answer there).

    Thanks again
    You have to know before dreaming !

  5. #5
    Ext User
    Join Date
    Jul 2007
    Location
    Florida
    Posts
    9,996
    Vote Rating
    5
    mjlecomte will become famous soon enough mjlecomte will become famous soon enough

      0  

    Default


    Basically some components use initialConfig when they are created. I listed which in that post I pointed you to above. In those situations you'll need to pass the required configs as a literal inside the constructor for a new instance or explicitly apply directly to initialConfig like evant or I show in initComponent. I think evant's way has lower overhead, you just have to know when to do it. My way is a more general work around. A third way would be to use the Ext 1 way of extending classes.

Thread Participants: 2

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