1. #1
    Sencha User
    Join Date
    Nov 2011
    Posts
    28
    Answers
    2
    Vote Rating
    0
    karpatyx@ya.ru is on a distinguished road

      0  

    Default Answered: Creating new forms

    Answered: Creating new forms


    Hi guys.

    I have a question about who and when creates forms instance I use. Example:

    I have view:

    Code:
    /// <reference path="extjs/ext-debug.js" />
    /// <reference path="extjs/ext-all-debug-w-comments.js" />
    
    
    Ext.define('ikhtml.view.login.LoginView', {
        extend: 'Ext.window.Window',
        alias: 'widget.login',
        title: 'Login View',
        layout: 'fit',
        modal: true,
        resizable: false,
        closable: false,
        closeAction: 'hide',
        items: [...],
        buttons: [...]
    });
    Controller:

    Code:
    /// <reference path="extjs/ext-debug.js" />
    /// <reference path="extjs/ext-all-debug-w-comments.js" />
    
    
    Ext.require('Ext.window.MessageBox');
    
    
    Ext.define('ikhtml.controller.LoginController', {
        extend: 'Ext.app.Controller',
    
    
        views: [
            'login.LoginView'
        ],
    
    
        init: function ()
        {
            this.application.on({
                needLogin: this.onNeedLogin,
                scope: this
            });
        },
    
    
        onNeedLogin: function ()
        {
            console.log('onNeedLogin');
            var login = Ext.widget('login');
            login.show();
        }
    });
    App.js:
    Code:
    /// <reference path="extjs/ext-debug.js" />
    /// <reference path="extjs/ext-all-debug-w-comments.js" />
    
    
    Ext.application({
        name: 'ikhtml',
    
    
        controllers: [
            'DesktopController',
            'LoginController'
        ],
    
    
        launch: function ()
        {
            Ext.state.Manager.setProvider(Ext.create('Ext.state.LocalStorageProvider'));
    
    
            Ext.state.Manager.set('sessionId', null);
            Ext.state.Manager.set('userName', 'guest');
    
    
            Ext.create('Ext.container.Viewport', {
                layout: 'fit',
                items: [
                    {
                        xtype: 'desktop'
                    }
                ]
            });
        }
    });
    So, not too much code?
    As you see, App.js creates view of 'desktop' type. Desktop controller sends appliction-level message, Login Controller gets it and shows Ext.widget('login');

    So, when is this Ext.widget('login') created? I don't see any piece of code that calls its constructor.

    Does this mean that each call to Ext.widget('login') will create separate instance? Or it acts like a singleton? Or it was somehow created during application init?

  2. Ext.widget will create a new instance of the view. If you only want one view, the Controller actually already created an instance.

    When you specify a view in the views Array in the Controller, a getter method is created and the view is actually also instantiated. Instead of doing Ext.widget, you could use the getter to get the view instance.

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,756
    Answers
    3462
    Vote Rating
    828
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Ext.widget will create a new instance of the view. If you only want one view, the Controller actually already created an instance.

    When you specify a view in the views Array in the Controller, a getter method is created and the view is actually also instantiated. Instead of doing Ext.widget, you could use the getter to get the view instance.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  4. #3
    Sencha User
    Join Date
    Nov 2011
    Posts
    28
    Answers
    2
    Vote Rating
    0
    karpatyx@ya.ru is on a distinguished road

      0  

    Default


    Cool, now it's much more clear!

    Thanks.

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