How exactly does a view listen to the model in MVC?
I understand the architecture. You have a model with data, a view that displays, and a controller that regulates between the two. What I don't understand is how you can update your view when the model changes (in push mvc format). Like if I have a textfield displaying an integer from my model, and my model changed, how would the textfield update?
I'm told in my specifications to "The role of ModelChanged is to update the current view due to changes in the model. This class will have a handler/listener that implements the actionPerformed."
Is there a specific type of action listener that knows when the model is changed?
Re: How exactly does a view listen to the model in MVC?
Re: How exactly does a view listen to the model in MVC?
Thanks for the reply! I understand the link, but I was more wondering what specific listener code will query a model using actionPerformed? For instance, I could create a button that when pressed would access the controller who would then return the model's specific information to the view. But I have to click the button. How do I do this with something like a JTextField or a message or anything static, that doesn't require pressing?
Re: How exactly does a view listen to the model in MVC?
Quote:
Originally Posted by
AWJustAGuy
Is there a specific type of action listener that knows when the model is changed?
You can see examples of these in the API: TableColumnModelListener, TableModelListener and TreeModelListener.
db