• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question on MVC object creation

 
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a question on how the objects in an MVC pattern are created. Does another controller open all three - model, controller and views. Or, does
another controller open your controller, then your controller open the model and views. I'm thinking in terms of a large application that has many
mvcs.

Thanks.
 
Ranch Hand
Posts: 99
Android Mac Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I do not think you can have many mvcs in one application. The application as a whole must follow the MVC principle.
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think we can have multiple front controllers in a single web application.
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I believe We can have multiple controller instances in an application. For example, in business deligate pattern, we can define the same controller class by making the entry in web.xml(thereby a new instances for every business deligate will be created by the server).

<servlet>
<servlet-name>Delegate1</servlet-name>
<display-name>Delegate1</display-name>
<servlet-class>FrontController</servlet-class>
</servlet>
<servlet>
<servlet-name>Delegate2</servlet-name>
<display-name>Delegate2</display-name>
<servlet-class>FrontController</servlet-class>
</servlet>

Please correct me if I am wrong.
 
Deepak Shankar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To answer Barry's question,
There is no specific rule that controller should create model and model should create a view etc. It is based on the framework.

If you take web applications, the controller "create" model instances and "invoke" view instances. In this case I have said "invoke" because the control is forwarded to the web container for creating the view instance. What the controller can do is just say response.forward() or response.redirect().

And generally we do not instantiate one controller from another controller.

Hope this helps.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic