View Full Version : Ext.application() vs Ext.create('Ext.app.Application')

17 Apr 2012, 9:53 AM
I've converted our app to use dynamic loading and working with the SDK tools. We have a base app and each client will have its own app.js. 90% of each client's app.js will be shared among all clients and ideally I would like to make a BaseApp.js and have app.js extend it.

So I thought I would start out just converting this:

name: 'Csg',

glossOnIcon: true,

To this:

Ext.create('Ext.app.Application', {
name: 'Csg',

glossOnIcon: true,

and it blows up on Ext.ComponentQuery.query(selector, this); I add Ext.ComponentQuery to requires[] and it blows up somewhere else.

So I'm guessing I might be going down the wrong path doing an Ext.create() for the app. How can I make a BaseApp.js and have each client's app.js extend that? I can't find a way to make it work with Ext.application().

17 Apr 2012, 10:14 AM
You could override Ext.application to use something other than Ext.app.Application or of course roll your own Ext.application method. It's pretty easy to understand what Ext.application is, it's in src/core/Ext-more.js about half way down:

application: function(config) {
var appName = config.name,
onReady, scope, requires;

if (!config) {
config = {};

if (!Ext.Loader.config.paths[appName]) {
Ext.Loader.setPath(appName, config.appFolder || 'app');

requires = Ext.Array.from(config.requires);
config.requires = ['Ext.app.Application'];

onReady = config.onReady;
scope = config.scope;

config.onReady = function() {
config.requires = requires;
new Ext.app.Application(config);

if (onReady) {


17 Apr 2012, 1:30 PM
Before posting I looked at the source code and hate to override/modify base code. I tried doing a mixin and it doesn't seem to get applied. Maybe Ext.app.Application doesn't support them? Try some other things now.

18 Apr 2012, 4:06 AM
Ext.app.Application should support mixins, you just need to manually execute the constructor of the mixin.

I wouldn't override Ext.application either, I would create my own that does the same thing just more configurable.

18 Apr 2012, 5:36 AM
Mitchell - I was over-thinking this (and being stubborn trying to make it work). Ripped out launch and the functions it uses from app.js and put them in a Main controller. Works great and if any clients need additional functionality I can extend or override this controller.

Now our app.js is used for dependencies and onUpdated() which it probably should have been in the first place. We need to keep our app.js dumb and everything else goes into controllers.

Thanks for the help.