To illustrate my problem, let's say I have a Thing instance that has two text properties: "foo" and "bar".
I want to create a panel for editing instances of Thing. The panel has two TextField components, one for the foo property and one for the bar property.
I want to be able to call setDefaultModel() in my panel with an instance of IModel<Thing> and refer to this model for TextField components. What is the best way to achieve this?
Should I override the Panel.setDefaultModel() method to also call setModel () on the two TextField components? Or perhaps create anonymous ReadOnlyModels for TextField components by overriding the getObject() method to extract an object from the Panel Panel model?
None of them seem very elegant to me, so I was wondering if there is a better way?
source share