onchange使用radioChoice获取当前值

onchange使用radioChoice获取当前值

本文介绍了onchange使用radioChoice获取当前值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用radioChoice onChange从单选表单中获取选定的值,但实际上似乎找不到解决方案.会调用onEvent函数,但是从这里我不确定如何获取值.

Im trying to get the selected value from a radio form with radioChoice onChange but can't really seem to find the solution. The onEvent function gets called, but from here I'm not really sure how to get the value.

代码:

    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);

推荐答案

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

you should use AjaxFormChoiceComponentUpdatingBehavior instead of AjaxFormComponentUpdatingBehavior. See Javadoc:

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

这篇关于onchange使用radioChoice获取当前值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 03:46