Interaction Between MVC Components
by, 04-26-2012 at 08:41 PM (827 Views)
In this section, a closer look will be taken to do the implementation of Fig. 1, in context of the application which is present in Java SE 6. Once view, model and controller objects get instantiated, this will happen:
1. At the model, view is being registered as listener. Changes being done to the model’s data would be instantly resulting into a change notification that will be received by the view. This is the most common example of “push model”. It shall be noted that model doesn’t know anything about controller and view. It just send change notifications to all listeners.
2. Controller is view bounded. Typically this means that user actions at view will be invoking the registered listener methods, in controller class.
3. Reference is given to controller, to the underlying model.
Once an interaction of user is done with the view, this action occur:
1. GUI actions recognized by the view. For example, scroll bar dragging or button pushing, listener method is used which can be called whenever this kind of action takes place.
2. On the controller, appropriate method is called by the view.
3. Model is accessed by the controller, which updates in an appropriate method to the actions of the user.