Model Wicket 6:嵌套对象';没有伊莫代尔的喧闹

Model Wicket 6:嵌套对象';没有伊莫代尔的喧闹,model,wicket,wicket-6,wicket-1.6,Model,Wicket,Wicket 6,Wicket 1.6,我有嵌套模型,如: class User { private String name; private Address address; ... } class Address { private String city; ... } 现在,在Wicket 6中,我可以使用单个IModel访问所有嵌套属性,如: IModel<User> userModel = new PropertyModel<>(user); Form<User>

我有嵌套模型,如:

class User {
  private String name;
  private Address address;
  ...
}

class Address {
  private String city;
  ...
}
现在,在Wicket 6中,我可以使用单个IModel访问所有嵌套属性,如:

IModel<User> userModel = new PropertyModel<>(user);
Form<User> form = new CSRFSafeForm<>("form", user);
form.add(new TextField<>("name"));
form.add(new TextField<>("address.city"));
IModel userModel=新属性模型(用户);
表单=新的CSRFSafeForm(“表单”,用户);
添加(新文本字段(“名称”));
添加(新文本字段(“地址.城市”);
不需要任何额外的编码就可以了吗

我读过Wicket的手册,但它说我需要创建一个新的表单和IModel


可以在同一个表单上编辑姓名和城市吗?

我不知道CSRFSafeForm来自哪里

但您可以对标准表单和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"));
IModel userModel=新属性模型(用户);
表单=新表单(“表单”,新的CompoundPropertyModel(用户));
添加(新文本字段(“名称”));
添加(新文本字段(“地址.城市”);
您可以删除代码中的“userModel”(第一行),以避免混淆。