AjaxFormComponentUpdatingBehavior在Wicket 8中无法正常工作

3

我正在从Wicket 6切换到Wicket 8,但是AjaxFormComponentUpdatingBehavior似乎不再起作用。

示例页面:

    public HomePage() {
        final Form<Void> form = new Form<>("form");
        final TextField<String> txt = new TextField<>("txt", new Model<>());
        txt.add(new AjaxFormComponentUpdatingBehavior("onchange") {
            private static final long serialVersionUID = 1L;

            @Override
            protected void onUpdate(final AjaxRequestTarget target) {
                System.out.println("update: " + txt.getValue());
            }
        });
        form.add(txt);
        add(form);
    }

并且相应的HTML:

<form wicket:id="form">
<input wicket:id="txt">
</form>

在Wicket 8.5.0中,onUpdate方法从未被调用,并且没有错误消息。在Wicket 6中它可以正常工作。其他组件类型也会出现相同的问题,例如select/DropDownChoice。
这是一个bug吗?还是我做错了什么?

2
如果您尝试将“onchange”替换为“change”,会发生什么?我的印象中,事件名称不再需要前缀,但我不确定是哪个Wicket版本引入了这个更改。 - Jeroen Steenbeeke
1
@JeroenSteenbeeke 嗯,你说得对,似乎在两个版本中都可以使用 change。你应该把这个发表为答案。 - aditsu quit because SE is EVIL
1个回答

9

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接