In order to make this task as easy as possible, Wicket offers two special model classes: However this solution has a huge drawback: the text displayed by the label will be static and if we change the value of the field, the label won't update its content.
Instead, to always display the current value of a class field, we should use the Property Model has just one constructor with two parameters: the model object (person in our example) and the name of the property we want to read/write ("name" in our example). Internally, methods get Object/set Object use property expression to get/set property's value.
In Wicket a model is any implementation of the interface The IModel interface defines just the methods needed to get and set a data object (get Object() and set Object()), decoupling components from concrete details about the persistence strategy adopted for data.
It can wrap any object that implements the interface The reason of this constraint over data object is that this model is stored in the web session, and we know from chapter 6 that data are stored into session using serialization.The Model class comes with a bunch of factory methods that makes it easier to build new model instances.For example the of(T object) method creates a new instance of Model which wraps any Object instance inside it.Model is essentially a facade interface which allows components to access and modify their data without knowing any detail about how they are managed or persisted.Every component has at most one related model, while a model can be shared among different components.Inheritable models are those which implement interface has been inherited by a component, it will behave just like a Property Model using the id of the component as property expression.