PDA

View Full Version : Views not loaded by Ext.application



neo1010
17 Oct 2014, 1:24 AM
When defining the next in ExtJS 4.2:



Ext.application({
name: 'Demo',
appFolder :'app',
controllers : ['Users'],
models: ['User'],
stores: ['Users'],
views : ['user.List', 'user.Edit'],
launch: function() {
Ext.create('Ext.container.Viewport', {
layout: 'fit',
items: [
{
xtype: 'gridUsuarios'
}
]
});
}

1. The js view files are not loaded and I dont know why because in the api it shows this property. Although the documentation says the next in an example: "Note that we didn't actually list the Views directly in the Application itself. This is because Views are managed by Controllers, so it makes sense to keep those dependencies there", it should load these files in the Ext.Application, right?


2. When defining your views in the Controllers instead of in the Ext.Application, you just get to download the related js files or are there other advantages ?

Thanks

slemmon
18 Oct 2014, 12:48 AM
1. The js view files are not loaded and I dont know why because in the api it shows this property. Although the documentation says the next in an example: "Note that we didn't actually list the Views directly in the Application itself. This is because Views are managed by Controllers, so it makes sense to keep those dependencies there", it should load these files in the Ext.Application, right?


The file you'll load with the views config will be in the 'app' directory under 'view' and then any sub-folder you'd like. The views strings will represent where in that directory your view class lives. If the string is 'user.List' then the loader will look for the List class at app/view/user/List.js.

Is that how you have your application structure set up? Do you have a 'user' folder under app/view?


2. When defining your views in the Controllers instead of in the Ext.Application, you just get to download the related js files or are there other advantages ?

Ideally you'll set the view requirement on the controller where that view is instantiated. So, if the view is instantiated for the whole app in the Ext.application() setup in the launch() method then it will make sense to have it required in Ext.application().

neo1010
18 Oct 2014, 6:29 AM
Hy,

1. As you mentioned my folder structure is right and besides when I declare the views in the controller, they get loaded; I still dont get it why they dont get loaded from the Ext.application

2. I dont understand when you say the views "are instantiated", I mean, when I declare the property views, stores, controllers, models in Ext.application I just thought the related js files got loaded but nothing else, they were not instantiated. I think the controllers are instantiated but the rest are not, right?

3. I dont get when you say : " if the view is instantiated for the whole app ...." . For me declare a view in the Ext.application or in a controller just loads the js related but nothing else; it doesnt instantiate, I instantiate using a xtype or Ext.create or new ......

Thanks