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: {
fn: this.onLogin
},
Logout: {
fn: this.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');