Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Question on MVC object creation

 
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
  • 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.
 
It's a tiny ad only because the water is so cold.
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic