[英]Binding Set to form with ListItems in Wicket
So I work with Apache Wicket and I have the Model class with the attributes: 因此,我使用Apache Wicket,并且拥有具有以下属性的Model类:
private String name;
private Set<Details> details;
where Details class is Details类在哪里
private String detailsName;
private DetailsEnum detailsEnum;
and DetailsEnum is enum { SOME, MORE, MOST }. 并且DetailsEnum是枚举{SOME,MORE,MOST}。 I have problem with a Set of Details.
我对一组详细信息有疑问。 There is the ListView but it works with a List, not a Set.
有ListView,但它适用于List,而不适用于Set。 I need to have the form like this:
我需要这样的表格:
name:[ examplemodelname ] 名称:[ examplemodelname ]
detailsName : [here dropDownChoice with this enum] detailsName :[这里是这个枚举的dropDownChoice]
detailsName : [here dropDownChoice with this enum] detailsName :[这里是这个枚举的dropDownChoice]
detailsName : [here dropDownChoice with this enum] detailsName :[这里是这个枚举的dropDownChoice]
But I don't know how to bind Set in a proper way. 但是我不知道如何以适当的方式绑定Set。
Do you want create 3 dropDownChoice, but in your model you have set of Details. 是否要创建3 dropDownChoice,但在模型中有一组Details。 Can't be sure that in set exist 3 objects.
不能确定集合中存在3个对象。
I would change Model: 我会改变型号:
private String name;
private DetailsEnum detail1;
private DetailsEnum detail2;
private DetailsEnum detail3;
And in your form with CompundPropertyModel of your model: 并在您的模型中使用模型的CompundPropertyModel:
form.add(new DropDownChoice<>("detail1"), Arrays.asList(DetailsEnum.SOME, DetailsEnum.MORE, DetailsEnum.MOST), new Arrays.asList(DetailsEnum.values()));
form.add(new DropDownChoice<>("detail2"), Arrays.asList(DetailsEnum.SOME, DetailsEnum.MORE, DetailsEnum.MOST), new Arrays.asList(DetailsEnum.values()));
form.add(new DropDownChoice<>("detail3"), Arrays.asList(DetailsEnum.SOME, DetailsEnum.MORE, DetailsEnum.MOST), new Arrays.asList(DetailsEnum.values()));
You also can rewrite the displayed value, except of new Arrays.asList(DetailsEnum.values())
write new EnumChoiceRenderer<DetailsEnum>(this)
and define something like this in property file: 您还可以重写显示的值,除了
new Arrays.asList(DetailsEnum.values())
之外,还可以编写new EnumChoiceRenderer<DetailsEnum>(this)
并在属性文件中定义如下内容:
DetailsEnum.SOME=Some
DetailsEnum.MORE=More
DetailsEnum.MOST=Most
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.