我试图用DropDownChoice
创建一个setNullValid(true)
,我给模型一个有Class A
的Class B
,我给它一个B类列表来选择,如果A类已经有B类,那么选择的B类没有' t在渲染时显示为已选中。
如果A.b不为null,我希望已经选中,但其中一个选项为null。
感谢您的时间
DropDownChoice<B> bChoices = new DropDownChoice<>(DROPDOWN, new PropertyModel<>(a, "b"),
listOfBs, new ChoiceRenderer<>("name"));
b.setNullValid(true);
Wicket使用IChoiceRenderer#getIdValue()
查找所选选项。如果你不提供自定义IChoiceRenderer
,那么Wicket将使用ChoiceRenderer
,并且作为id
,它将使用List
选项中项目的索引。
在#equals()
上查看https://github.com/apache/wicket/blob/7bef3d67c8ccc269f02e8943bf9a22c3cd5438e9/wicket-core/src/main/java/org/apache/wicket/markup/html/form/AbstractSingleSelectChoice.java的用法。更好的解雇调试器,看看会发生什么!