PDA

View Full Version : Extending controller from a different Package



sarasa
22 Apr 2013, 2:56 AM
Hi,

I have huge application.
I would have a common folder with common extjs files across multiple extensions.
Extension folder will extend basic view from common and add its own components.
My application structure would be

common
-app
--model
--view
--store
--controller
---CommonController.js(controller file)

extension1
-app
--model
--view
--store
--controller
---Extension1Controller.js (This should extend CommonController.js)
app.js


app.js



Ext.Loader.setConfig({enabled:true});
Ext.Loader.setPath('Ext.ux', 'extjs/ux');
Ext.Loader.setPath('commonapp', '/common/app');
Ext.require([
'Ext.data.*',
'Ext.grid.*',
'Ext.tree.*'

]);


Ext.application({
name: 'NSM',
appFolder: '/extension1/app',

controllers: [

'Extension1Controller'

],
launch: function() {

Ext.create('Ext.panel.Panel', {
layout: 'fit',
renderTo:'contentContainer',

items: [
{
xtype: 'panel'

}
]
});

}
});


Extension1Controller.js


Ext.define('NSM.controller.Extension1Controller', {
extend: 'commonapp.controller.CommonController', //Extending the controller from common






init: function() {
//this.getWPPolicyStoreStore().addListener('write',this.finishedLoading, this);

console.log("in sample controller");
}


});

But extending throws following error

Uncaught Error: The following classes are not declared even if their files have been loaded: 'commonapp.controller.CommonController'. Please check the source code of their corresponding files for possible typos: '/common/app/controller/CommonController.js

Please help.

slemmon
24 Apr 2013, 8:23 AM
In your Extension1Controller definition if you extend from Ext.app.Controller and just do a requires: ['commonapp.controller.CommonController'] do you get an error that it can't load that js file?