title: ExtJS 4 MVC multiple instances of views and sub/child controller difficulties
body: <p>I have encountered a problem with the MVC pattern in ExtJS 4. At least, I think I have. Having approached multiple people with this question, and having posted numerous times in the Sencha forums, I am now turning to a broader audience in hopes of getting either a light bulb or a confirmation.</p>
  
  <p><strong>Problem</strong></p>
  
  <p>Your application has the ability to open many different views, some of which themselves are mini-applications. Additionally, a user may wish to have multiple concurrent copies of a view open.</p>
  
  <p>This application is a single-page client-side Javascript application.</p>
  
  <p>The ExtJS 4 MVC model expects you to define all of your controllers in your Application class. These controllers are then initialized when the Application loads. Controllers keep track of views, models and stores. </p>
  
  <p>When you initialize controller A multiple times, say to create more than one copy of a view, you end up with two views that reference the same data stores, and functionally send duplicate events to the Application event bus.</p>
  
  <p>I have refactored my application by adding new prototype methods to Component and Controller to allow for both a) sub controllers (some of my controllers were getting pretty huge) and b) defining stores specifically for the view they work with. The models can still be defined on the controller, just for ease of use by handlers if you need to do something like grab a record from the server. </p>
  
  <p><strong>Question</strong></p>
  
  <p>My understanding of MVC would lead me to believe that models more directly relate to the View than then Controller. <strike>I asssssume that ExtJS 4 decides to attach stores (which I think can be seen as wrappers to a more classic model) to Controllers for purposes of encouraging re-use of loaded data, and to optimize away from having many copies of the same class instantiated. It seems to me, however, that one cannot do this if one intends to have many instances of a view available to the user. To my thinking, having many instances is an important option in an OO framework, hence why I have bucked the trend and implemented prototypes on some of the Ext base classes. (Thank you Ext.implement!).</strike></p>
  
  <p>Is there any way to have multiple concurrent instances of a view with <strong>different data loaded into them</strong> using the out of the box MVC classes and making uses of the provided setters, getters, etc? </p>