简体   繁体   中英

Is it useful to use mediator pattern with MVC?

The question is about ideology of the MVC design pattern. By definition, the view is communicating with the controller directly. For instance, in JSF as well as ASP.NET web-forms , we can bind the property of the controller to a specific area of a web-page. But in this case we're doing that by directly wirte an expression like

<h:outputText value="#{partnerController.lastAccessDate}"/>

Would it be useful to create a mediator between views and controllers? I need, for instance, "send a message" to a several controller in a specific way.

In a traditional web application where a JSP page (or PHP or some other HTML generator) generates a form which is filled by the user and posted back to the server, this does not make a lot of sence. The posted form is sent directly to a controller which handels the data.

In fat client environment this makes a lot fo sence. The fat client can be something like SWING or a JavaScript framework like Angular. Here the controller acutally is a mediator. What it does is often called data binding. It makes sure the data entered into the GUI is stored in the business objects which gets eventually sent accros the wire or persisted.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM