Reputation: 9081
I have done an Asp.net mvc application. When I finished it I see this diagram
Microsoft’s Smart Client Factory documentation
I don't understand the direct communication between the model and the view in the mvc pattern, I never seen such thing.
So I need to know :
Upvotes: 0
Views: 829
Reputation: 536
The diagram you showed is a MVC application that is not bound to http shortcommings - like a windows form application or anything similar. There you can send some information from the model like "hey look - i got some new data".
For the web this is not possible (without AJAX/SignalR/...). You do not have that dotted line. A bit simplified (as you can have many filters and models and other plugin points) the controller gathers the input (if any) and asks or creates the (View) Model which is returned as ActionResult. Then the view (e.g. with Razor view engine) is created and sent to the browser.
From there on no connection is between what the user recognizes as his view (what the browser shows him) and the view created on the web server. Therefor no events can be sent between them.
If you need a connection between the (server side) model and the (server side) view then this could be done with events or notify property changed etc.
Upvotes: 1
Reputation: 10561
As you can see the diagram has a dashed line between the model and view. To my understanding this means that the connection is not direct. To me this looks like a reference to some kind of observer pattern. Some client-side technologies like Facebook React and AngularJS have an implementation of the observer pattern. That is, the view "looks" at the model and when the model changes, the view re-renders itself to reflect the change in the view.
In this way you could look at it backwards and say that the update of the model is triggering an event of the view, which in tern re-renders the view. I think this is what the dashed line means in this diagram.
You could implement this manually in an MVC view, but you could also leverage the frameworks I mentioned above.
Upvotes: 1