3
votes

This might look like a dumb question but I am new to MVC particularly to extJs. I wish to work with the MVC approach. I followed this link http://www.extjsframework.com/mvc/simple-mvc-application. But it has only a single page as example. The example page uses app.js to load extjs views. Now here is my question. I have an application with multiple pages. Do i need to make separate app.js like scripts for each page of my app or could i use the same app.js accross all my pages. If i could, kindly mention how. Thanks...

4
Ideally, you entire app should be just one traditional 'page'. All other 'traditional pages' will be replaced by Ext Windows, etc. This is one of the assumptions of the 100% client side MVC architecture as in the link you posted above. If for some reason, you still need multiple 'web pages', 'extjs mvc' does not apply to/cover interaction between those web pages.Amol Katdare
where any answers below helpful?dbrin

4 Answers

2
votes

All of the answers here are correct, however the question seems to be a bit ambiguous so that's why they are all slightly different.

The typical RIA app is a single HTML(or php,jsp,asp) page with many different views all managed by the the JS framework, so changing pages is no longer required (and in most cases avoided for performance reasons).

Your server side code/scripts are then typically reduced to JSON data services that provide data to the RIA app running completely independently in the client browser.

As you can see you would not need to have test.php and index.php and would suffice to have one index.php with ExtJS application running out of that page.

If this answer is not useful because you already knew all of this and really meant to ask about multiple controllers and modularization of an ExtJS application then that's a separate discussion and has been addressed to an extent in other posts. (look for lazy loading controllers).

Hope this helps.

0
votes

Every page. Every time a page unloads, it's like the JS slate gets cleared. The browser will actually cache the files but the code executes like it was the first time.

0
votes

Usually it's same app.js for all different views.

0
votes

The MVC concept of ExtJS 4 is about architecture. The documentation clarifies that pretty easily.

Every Ext JS 4 application starts with an instance of Application class. The Application contains global settings for your application (such as the app's name), as well as maintains references to all of the models, views and controllers used by the app. An Application also contains a launch function, which is run automatically when everything is loaded.B

As you can see in the docs, you will have one single app.js, that is gonna be like a bootstrap, responsible to instantiate the whole application.

You are gonna structure your files, however, following the MVC approach, or pattern, in order to have a nice and clean architecture.