I have nested models like:
class User {
private String name;
private Address address;
...
}
class Address {
private String city;
...
}
now, in Wicket 6, can I have a singe IModel to access all nested properties like:
IModel<User> userModel = new PropertyModel<>(user);
Form<User> form = new CSRFSafeForm<>("form", user);
form.add(new TextField<>("name"));
form.add(new TextField<>("address.city"));
Is it possible without any additional coding?
I've read Wicket's manual https://cwiki.apache.org/confluence/display/WICKET/Working+with+Wicket+models but it says I need to create a new form and IModel.
Is it possible to edit both name and city on the same form?
I don't know where CSRFSafeForm is coming from.
But you can do the same with a standard Form and CompoundPropertyModel:
IModel<User> userModel = new PropertyModel<>(user);
Form<User> form = new Form<>("form", new CompoundPropertyModel<User>(user));
form.add(new TextField<>("name"));
form.add(new TextField<>("address.city"));