View Full Version : Ext.app.Application. Objects creation sequence and using Options Objects

I'm Dennis
21 Nov 2011, 3:26 AM
Hey everyone
I'm trying to build proper Application using Ext.application approach and forcing problem of using objects in configs(options).

This breif example shows what I'm talking about:

name: 'myApp',
controllers: ['Index']

Should create a simple app with global var myApp, right?
Further it creates some myApp.controllers.Index var for desired Index controller.

Ext.define('myApp.controller.Index', {
extend: 'Ext.app.Controller',
stores: ['MyCustomStore'];

// I create this method here to be used in several Stores and not copy-pasted there
myCustomFunctionToHandleRestExceptions: function(response) {


This code helps me create MyCostomStore to be used in application, right?
Next I try to create this store

Ext.define('myApp.store.MyCustomStore', {
extend: 'Ext.data.Store',
autoLoad: true,
proxy: {
type: 'rest',
url: '/myURLHere',
reader: {
type: 'json'
listeners: {
exception(): function(proxy, response, operation) {
if (response.status == 401) {
// following line tries to handle 401 response using Index controller. And fails

That red line fails due to myApp variable is not created at that moment and I'm trying to use it in Options object for listeners ...

1. Which is proper/common approach for situations like that? Should I use something like initComponent method in this case instead of my attempts to pass objects via config files?

2. Where to read the sequence of creation of all those objects (application, controller, store etc) in context of Ext.app.Application.


21 Nov 2011, 6:11 AM
you can controll the events of stores in your controllers as well.
there you have the application reference and it should be cleaner imho.