Does MVC define how one controller should communic

2019-06-21 05:43发布

I am referring to the general MVC design pattern (as defined in Wikipedia). When doing a GUI-intensive application, I would generally have many controllers, and sometimes a controller could send an event to another controller.

Does MVC in general defines how controller should communicate with controller? Could a controller be the model for a controller higher up in the hierarchy?

Example Suppose I have a window (which is represented by a controller/model/view), and that window is capable of launching another sub-window. The sub-window is modal, and will accept certain input. The input will affect certain processes in the main window.

3条回答
做个烂人
2楼-- · 2019-06-21 06:29

Referring to Wiki Model–View–Controller (MVC) is an architecture that separates the representation of information from the user's interaction with it.

With that said it don't define any event mechanism, so there is no specification for intra controller communication.

Now coming to your question.

you can have view rendered from one controller and submit data to another controller. that should just work fine.

define form with <form action = "parentcontroller/parentaction"> to make it happens.

查看更多
Rolldiameter
3楼-- · 2019-06-21 06:34

No a controller can not be a model for another controller. Controllers just can pass arguments through Get or Post

查看更多
The star\"
4楼-- · 2019-06-21 06:40

No. You can not do that with MVC. You want to use some kind of hierarchical pattern like one of the following two:

查看更多
登录 后发表回答