1. #1
    Sencha User
    Join Date
    Jan 2012
    Location
    Switzerland
    Posts
    15
    Vote Rating
    0
    hciftci is on a distinguished road

      0  

    Default Scope and applicaiton events

    Scope and applicaiton events


    Hi

    I try to build an application with Sencha Architect. The user must login before he can do anything. To achieve that, I’ve created an authentication view (a form in a modal Window) and an authentication controller. Additionally there is an application viewport:

    Screen Shot 2012-04-19 at 1.23.47 PM.png

    First the authentication view is displayed. When the user clicks the login button, an AJAX request is send to the backend and the when receiving a response from it, the onLoginResponse method is called:

    Authentication.js
    PHP Code:
    var responseArray Ext.JSON.decode(response.responseText),
        
    authStore Ext.data.StoreManager.lookup('Authentication');

    authentication Ext.create('App.model.Authentication');
    authentication.set('id'responseArray.data[0].id);
    authentication.set('firstName'responseArray.data[0].firstName);
    authentication.set('lastName'responseArray.data[0].lastName);
    authentication.set('role'responseArray.data[0].role);
    authentication.set('authorization'responseArray.data[0].authorization);

    authStore.add(authentication); 
    In case the login is successful, I would like to fire an application global event:

    PHP Code:
    this.application.fireEvent('login'); 
    However, I have two problems until now. First, the actions created by Sencha Architect don’t have a scope property. I would like to set the application controller scope where I can access the references:
    Screen Shot 2012-04-19 at 1.20.24 PM.png
    app.js
    PHP Code:
    init: function() {

            
    this.application.on({
                
    Login: {
                    
    fnthis.onLogin
                
    },
                
    Logout: {
                    
    fnthis.onLogout
                
    }
            });

    The second question is, how do I fire the application global event? this.application returns the authentication controller:
    PHP Code:
    console.log(this.application);
    this.application.fireEvent('login'); 

  2. #2
    Sencha User
    Join Date
    Oct 2011
    Location
    Germany
    Posts
    50
    Vote Rating
    10
    apsq will become famous soon enough

      0  

    Default


    You don't need to set a context ("scope") for controller actions as these will always be executed in the scope of the controller.

  3. #3
    Sencha User
    Join Date
    Jan 2012
    Location
    Switzerland
    Posts
    15
    Vote Rating
    0
    hciftci is on a distinguished road

      0  

    Default


    Thank you for your reply apsq. However, still I need a way to fire the events defined in the App.js within the Authentication controller. How can I do that?

Thread Participants: 1