MVC modular GUI components

2019-06-07 05:34发布

问题:

I am trying to find the way to build complex web pages with MVC3 and AJAX.

I would like to use components to achieve this. Each component is consisted of it's own model, view and controller.

Multiple components are then placed on some complex view and should act together to provide desired behaviors.

In some situations, when user performs some action (interaction) with one of the components, I must update other portions of the page via AJAX. Component on which action (interaction) occurred, in it's implementation, does not assume anything about view on which it will be used and what portions of the pages should be updated and how.

So when some interaction occurs in some component, I need a mechanism (outside component itself) which will handle this situation and update appropriate parts of the page. How would you, generally, implement such mechanism?

回答1:

I would use the Mediator Pattern, also sometimes mistakenly referred to as the manager pattern.

This class would mediate the communication of your components.