aspose file tools*
The moose likes OO, Patterns, UML and Refactoring and the fly likes Question on MVC object creation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Question on MVC object creation " Watch "Question on MVC object creation " New topic
Author

Question on MVC object creation

Barry Brashear
Ranch Hand

Joined: Jun 05, 2001
Posts: 303
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.
Suman Mummaneni
Ranch Hand

Joined: Dec 14, 2004
Posts: 87
I do not think you can have many mvcs in one application. The application as a whole must follow the MVC principle.


Suman Mummaneni
Bangalore
India
Sarath PS
Greenhorn

Joined: Oct 22, 2004
Posts: 11
I think we can have multiple front controllers in a single web application.
Deepak Shankar
Greenhorn

Joined: Dec 14, 2005
Posts: 12
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

Joined: Dec 14, 2005
Posts: 12
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.
 
Don't get me started about those stupid light bulbs.
 
subject: Question on MVC object creation