我一直在尝试调试为什么我的 DropDownChoice 在一个简单的表单中只有 DropDown 和一个提交按钮几个小时以来都不能正常工作。
它有一个非常奇怪的行为。在下拉选项中选择的第一个值成功发送到服务器之后,模型不会更新任何其他选项选择。即,如果我有一个列表人员,并且我选择了第二个人,它会成功提交。但是,在选择另一个人并尝试再次提交时,它会一直显示第一个选择的选项。
这里的代码片段:
ChoiceRenderer<Empowerment> empowermentChoiceRenderer = new ChoiceRenderer<>("name", "id");
final DropDownChoice<Empowerment> empowermentDropDownChoice =
new DropDownChoice<>("empowerment", new PropertyModel<Empowerment>(this, "empowerment"), empowermentList, empowermentChoiceRenderer);
empowermentDropDownChoice.setRequired(true);
add(empowermentDropDownChoice);
我能够获得体面行为的唯一方法是将上面的授权变量设置为空。在这种情况下,在提交时,授权被重新初始化为 null,然后新的提交正常工作。
授权只是一个 JPA 实体。
我很高兴知道这是否是一个已知问题。我在 wicket 6.9.1 和 wicket 6.12 中体验过