Reputation: 2301
The page has a model,I have done setDefaultModel()
. I have a label added to the page:
Label name=new Label("name", new PropertyModel<String>(getDefaultModel(), "name"));
add(name);
Later, the page's model changes. But the property model's target model is still the original page's model.
What can I do to keep the property model updated when the target model changes?
Upvotes: 0
Views: 69
Reputation: 5681
Usually I advise against using setDefaultModel()
or setModel()
, exactly because of this type of problems.
Alternatively you can add another indirection:
new Label("name", new PropertyModel<String>(this, "defaultModel.name"));
... or with Wicket 8:
new Label("name", () -> ((Foo)getDefaultModel()).getName());
Upvotes: 2