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.

回答1:

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

  • PAC
  • HMVC


回答2:

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



回答3:

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.