PDA

View Full Version : Load Project Common Models



varunach
2 Aug 2012, 5:56 AM
Hi,

I have a folder structure similar to the one defined below:

js
-com
-ideas
-model
Combo1Model.js
Combo2Model.js
-widgets
Combo1Store.js
Combo2Store.js
-dashboard
-app1
-controller
controller.js
-model
model.js
-view
view.js //Combo1Store
app1.js
-app2
-controller
controller.js
-model
model.js
-view
view.js //uses Combo1Store
app2.js

Combo1Store and Combo2Store have the model config set in them.
Problem:
Both the view.js files use Combo1Store & Combo2Store . I don't want to define them twice in each of the apps. When I run the apps, the apps try and load the Combo1Model from http://localhost:8443/.../js/com/ideas/dashboard/app1/Combo1Model.js (http://.../app1/Combo1Model.js),
which is the incorrect path.

Combo1Store is defined as

Ext.define('com.ideas.widgets.Combo1Store', { extend : 'com.ideas.widgets.Store',
model : 'Combo1Model',
url : 'common/combo1Model'
});

view.js is defined as


Ext.define('Ext.form.Panel',{
... .. //normal config
items : [{
xtype : 'combo',
store : Ext.create('com.ideas.widgets.Combo1Store')
fieldLabel : 'Combo1Store'
}]
});
My apps have the following config defined


Ext.application({
appFolder : '.',
paths : {
'com.ideas' : '../../../ideas'
},
// other configs
});

So how do I go about using this folder structure and loading the reusable models or do I need to redefine the models for each app?

varunach
2 Aug 2012, 9:33 AM
bump

varunach
3 Aug 2012, 1:43 AM
It was quite simple actually.
Simple provide the full path to the model object in the store and it loads

So the stores config now is



Ext.define('com.ideas.widgets.Combo1Store', {
extend : 'com.ideas.widgets.Store',
model : 'com.ideas.model.Combo1Model',
url : 'common/combo1Model'
});