More Wicket CompoundPropertyModel News
Just updated Wicket to enable even more CompoundPropertyModel magic! You can now use the following construct without pain:
The most important change is that you can just use the 'children' property as a model for a ListView, as you would any other property with any other Component.
/** Constructor */
public FooPage() {
Form form = new Form("form", new CompoundPropertyModel(new Person(), null);
add(form);
form.add(new TextField("name"));
form.add(new ListView("children") {
protected IModel getListItemModel(final IModel listViewModel, final int index)
{
return new CompoundPropertyModel(super.getListItemModel(listViewModel, index));
}
void populateItem(ListItem item) {
item.add(new TextField("name"));
item.add(new TextField("favouriteDoll"));
}
}
}
The area marked in bold allows you to add components to your listitem using a CompoundPropertyModel.
I think this is pretty cool, and makes working with Wicket feel like a charm.