Reputation: 231
I am learning Wicket and would like to know how PropertyModel retrieves its data dynamically.
I understand that in order to make Model dynamic we have to override the getObject method. Can someone explain the inner workings of PropertyModel?
Upvotes: 2
Views: 586
Reputation: 1235
PropertyModel usually gets its model object by invoking the getter for the given property expression on an object, for example new PropertyModel(object, "name")
will try to evaluate object.getInnermostModelOrObject().getName()
.
You can however pass a specific method name like this: new PropertyModel(object, "calculateName()")
, which will evaluate to object.getInnermostModelOrObject().calculateName()
.
If you pass an IModel as the backing object of PropertyModel, the model object properties will be returned instead (see ChainingModel), giving you dynamical model objects.
You can see the expression language here: https://ci.apache.org/projects/wicket/apidocs/7.x/org/apache/wicket/core/util/lang/PropertyResolver.html
Upvotes: 6