Search code examples
javascriptextjsmodel-view-controllerextjs4extjs-mvc

How to make a MVC login and main view using ExtJS


I want to ask which is the best way to manage multiple views in ExtJS 4.2 using MVC pattern.

I mean, if i must have a login form and then when someone got logged I must change to another view, how could I must do that?

Must I put Login and the other view into a ViewPort? Do anyone has any example how I could manage this? What structure do you suggest?


Solution

  • Your Login should be an independent View. Here is an example how you can structure your MVC code:

    Ext.application({
        name: 'xxx',
        models: [
            // ...
        ],
        views: [
            // ...    
        ],
        stores: [
            // ...
        ],
        controllers: [
            // ...
        ],
    
        // ...
    
        launch: function() {
            // at the beginning show only the login form
            this.showLoginView();
        },
        // when the login is successfull, show your main view
        login: function(username, password) {
            this.showMainView();
        }
    });