onchange通过radioChoice获取当前值

时间:2018-05-09 12:27:38

标签: java ajax apache wicket

我试图通过radioChoice onChange从无线电表单中获取所选值,但似乎无法找到解决方案。 onEvent函数被调用,但从这里我不确定如何获取值。

代码:

    RadioChoice<String> radioChoice = new RadioChoice<String>("radio", new PropertyModel<String>(this, "selected"),this.radioChoiceList);
    radioChoice.add(new AjaxFormComponentUpdatingBehavior("change")
    {
        @Override
        protected void onUpdate(AjaxRequestTarget target)
        {
            System.out.println("ajax here!");
        }
    });
    Form<?> form = new Form<Void>("form");

    add(form);
    form.add(radioChoice);

1 个答案:

答案 0 :(得分:1)

您应该使用AjaxFormChoiceComponentUpdatingBehavior而不是AjaxFormComponentUpdatingBehavior。见Javadoc:

https://ci.apache.org/projects/wicket/apidocs/7.x/org/apache/wicket/ajax/form/AjaxFormComponentUpdatingBehavior.html