我有一个与此问题类似的问题:Wicket:可以启用 Checkgroup Ajax 吗?
我正在使用 ListView,其中每个项目都有一个复选框。我还有一个“全选”复选框。我正在使用 CheckGroup
、CheckGroupSelector
和 Check
,一切都很好。现在有一个新要求,即在更新复选框时更改页面上其他一些控件的状态。
Nicktar 在上面链接的问题中的建议也是我首先想到的,但我一直无法找出如何将 AjaxCheckBox
与 CheckGroup
一起使用>/检查组选择器
。根据文档,您必须使用 Check
。
但在 这个在 2008 年的邮件中,Igor Vaynberg 还指出可以在 CheckGroup
中使用 AjaxCheckBox
。
我尝试将使用 Check
的位置替换为 AjaxCheckBox
,但它不起作用,CheckGroupSelector
找不到复选框不再了。
我还研究了在 CheckGroup
中使用 onSelectionChanged
方法,但据我所知,我想避免使用它,因为它会触发到服务器的另一次往返。
有人可以给我提示吗?或者还有其他好的解决方案吗?
顺便说一句,我使用的是 Wicket 1.4。
I have a problem similar to this question: Wicket: can Checkgroup be Ajax enabled?
I'm using a ListView where each Item has a checkbox. I also have a "select all" checkbox. I am using a CheckGroup
, CheckGroupSelector
and Check
and everything works great. Now there is a new requirement to change the state on some other controls on the page when the checkboxes are updated.
Nicktar's suggestion in the above linked question was the first that came to my mind, too, but I haven't been able to find out how it is possible to use AjaxCheckBox
with CheckGroup
/CheckGroupSelector
. According to the doc you have to use Check
.
But in this mail from 2008, Igor Vaynberg also states that it is possible to use AjaxCheckBox
in a CheckGroup
.
I tried it with just replacing where I used Check
with the AjaxCheckBox
, but it didn't work, the CheckGroupSelector
didn't find the checkboxes anymore.
I also looked into using the onSelectionChanged
method in CheckGroup
, but I'd like to avoid using this as it triggers another roundtrip to the server, as far as I understood.
Can someone give me a hint? Or is there another nice solution for this?
By the way, I'm using Wicket 1.4.
发布评论
评论(1)
为什么不能添加
AjaxFormChoiceComponentUpdatingBehavior
到CheckGroup
?来自
AjaxFormComponentUpdatingBehavior
的 JavaDoc:AjaxFormChoiceComponentUpdatingBehavior
是与CheckGroup
和RadioGroup
一起使用的行为。如果您将AjaxFormComponentUpdatingBehavior
与onchange
事件一起使用,您会遇到 此错误与 IE。
AjaxFormChoiceComponentUpdatingBehavior
正确处理此问题,添加CheckGroup
中每个Check
的onclick
事件处理程序。附带说明一下,Igor 在该邮件中指出,
CheckBox
可以替换为AjaxCheckBox
,而不是Check
。AjaxCheckBox
只不过是CheckBox
的一个方便子类,带有AjaxFormComponentUpdatingBehavior("onclick")
,如 来源显示。Why can't you add an
AjaxFormChoiceComponentUpdatingBehavior
to theCheckGroup
?From
AjaxFormComponentUpdatingBehavior
's JavaDoc:AjaxFormChoiceComponentUpdatingBehavior
is the behavior to use withCheckGroup
s andRadioGroup
s. If you used anAjaxFormComponentUpdatingBehavior
with theonchange
event, you'd run into this bug with IE.
AjaxFormChoiceComponentUpdatingBehavior
handles this properly, addingonclick
event handlers to each of theCheck
s in theCheckGroup
.As a side note, what Igor stated in that mail, is that
CheckBox
can be replaced withAjaxCheckBox
, notCheck
.AjaxCheckBox
is nothing more than a convenience subclass ofCheckBox
with anAjaxFormComponentUpdatingBehavior("onclick")
, as the sources show.