|
Navigation: Programming Cookbook > Creating GUI Applications > Creating MVP Components > Models |
![]() ![]()
|
The model data is usually described by a particular class in the image. Most often these are created beneath the Model hierarchy although, this is not essential. All that is necessary is that the model must trigger appropriate events for the view to intercept so that any changes made to it can be read displayed.
Here are some examples:
Domain Data |
Model class |
Events triggered |
Notes |
Text |
ValueModel or subclass |
#valueChanged |
The value model's value will be a String. An appropriate view must be chosen capable of displaying string values. |
Numbers |
ValueModel or subclass |
#valueChanged |
The value model's value will be a Number. An appropriate view must be chosen capable of displaying numeric values. |
Lists of things |
ListModel |
#listChanged |
The list model can typically hold any sort of object. It is up to the view to decide how this is displayed. |
Bank Account data (sample) |
PersonalAccount |
#currentBalanceChanged |
Taken from the Personal Money tutorial. This is a composite model (built of other models) that will require a composite view to display it (see later). |