如何从 AjaxCheckBox 的 onUpdate() 事件读取列表框的 PropertyModel 状态 - Apache Wicket
问题:用户在多选列表框中进行了一些选择,然后按下了复选框,并且选择丢失了。我需要保留选择。
我有一个扩展的报告向导(wicket.extensions.wizard.Wizard) 我有一个扩展 WizardStep.WizardStep 的步骤 在此步骤中,我有一个多选择框,它扩展了 wicket.markup.html.form.ListMultipleChoice 我添加如下:
final ChooseListMultipleChoice allPlansChoiceField = new ChooseListMultipleChoice(PLANS_SELECT_ALL_PLANS_LIST, new PropertyModel(this, "selectedAllPlans"), allPlans);
allPlansChoiceField.setOutputMarkupId(true);
add(allPlansChoiceField);
并且我还有AjaxCheckBox(wicket.ajax.markup.html.form.AjaxCheckBox) 像这样使用:
AjaxCheckBox displayArchived = new AjaxCheckBox(DISPLAY_ARCHIVED){
protected void onUpdate(final AjaxRequestTarget target) {
allPlans.clear();
final boolean isDisplayArchived = rawReportFilterInput.isDisplayArchived();
List listAllPlan = projectFacade.listActiveAndClosingPlans(isSort, isDisplayArchived);
allPlans.addAll(listAllPlan);
target.addComponent(allPlansChoiceField);
}
};
add(displayArchived);
在 onUpdate 方法内,模型“selectedAllPlans”不会根据当前用户选择进行更新。例如,如果我只有一个简单的 ajax 提交按钮,那么它将触发 onSubmit 事件,所有表单数据都将被传递,并且“selectedAllPlans”将填充用户选择。 当用户选中/取消选中 AjaxCheckBox 时,我需要完全相同的行为。到目前为止,我还无法使其正常工作,模型始终大小= 0。
标记:
<div class="effortsReport" style="height: 220px;">
<table>
<tr>
<input type="checkbox" wicket:id="plansSelect.displayArchived">
<br><div class="fixed_select"><select wicket:id="allPlansList"/></div></td>
</tr>
</table>
</div>
我希望得到一些建议和可能的解决方案。 此致, 奥列格
Problem: user made some selection in the multi-selection listbox, then pressed a checkbox, and selection got lost. I need the selection to be preserved.
I have a report wizard which extends (wicket.extensions.wizard.Wizard)
I have a step which extends WizardStep.WizardStep
On this step I have a mutli-selection box which extends wicket.markup.html.form.ListMultipleChoice
I add it as follows:
final ChooseListMultipleChoice allPlansChoiceField = new ChooseListMultipleChoice(PLANS_SELECT_ALL_PLANS_LIST, new PropertyModel(this, "selectedAllPlans"), allPlans);
allPlansChoiceField.setOutputMarkupId(true);
add(allPlansChoiceField);
and I also have AjaxCheckBox (wicket.ajax.markup.html.form.AjaxCheckBox)
Used like this:
AjaxCheckBox displayArchived = new AjaxCheckBox(DISPLAY_ARCHIVED){
protected void onUpdate(final AjaxRequestTarget target) {
allPlans.clear();
final boolean isDisplayArchived = rawReportFilterInput.isDisplayArchived();
List listAllPlan = projectFacade.listActiveAndClosingPlans(isSort, isDisplayArchived);
allPlans.addAll(listAllPlan);
target.addComponent(allPlansChoiceField);
}
};
add(displayArchived);
inside the onUpdate method the model "selectedAllPlans" is not updated with current user selection. For instance, if I had just a simple ajax submit buttom, then it would have triggered the onSubmit event and all form data would have been passed and "selectedAllPlans" would be populated with user selection.
I need the exact same behaviour when user checks/unchecks the AjaxCheckBox. So far, I haven't been able to make it working, model is always size = 0.
MarkUp:
<div class="effortsReport" style="height: 220px;">
<table>
<tr>
<input type="checkbox" wicket:id="plansSelect.displayArchived">
<br><div class="fixed_select"><select wicket:id="allPlansList"/></div></td>
</tr>
</table>
</div>
I would appreciate some advise, possible solutions.
Best regards,
Oleg
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我明白了,就这样做:仅此
而已。您甚至不需要存储/恢复状态,它就可以工作。是的,我们花了一些时间才发现这一点,但最终这是可能且容易的。一定要爱威克特。
Okay I figured it out, just do this:
and that's all. You do not even need to store/restore the state, it just works. Yes it took time to find this out, but it's possible and easy in the end. Gotta love Wicket.