onchange get current value with radioChoice

南笙酒味 提交于 2020-12-11 01:40:11

问题


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.

Code:

    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:


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



来源:https://stackoverflow.com/questions/50253445/onchange-get-current-value-with-radiochoice

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!