问题描述
我正在尝试使用setNullValid(true)创建一个DropDownChoice ,我给模型一个Class A ,上面有一个Class B ,我给它一个 B 类列表来选择,如果 A 类已经有 B 类选定的 B 类在渲染时未显示为选定。
如果 Ab 不为空,我希望已经被选中,但其中一个选项也为空。
感谢您的时间
DropDownChoice<B> bChoices = new DropDownChoice<>(DROPDOWN, new PropertyModel<>(a, "b"),
listOfBs, new ChoiceRenderer<>("name"));
b.setNullValid(true);
1楼
Wicket 使用IChoiceRenderer#getIdValue()来查找选定的选项。
如果您不提供自IChoiceRenderer ChoiceRenderer ,则 Wicket 将使用ChoiceRenderer并作为id ,它将使用选项List中项目的索引。
在查看#equals()的用法.
最好启动调试器,看看会发生什么!