onchange 使用 radioChoice 获取当前值
onchange get current value with radioChoice
我正在尝试使用 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);
您应该使用 AjaxFormChoiceComponentUpdatingBehavior 而不是 AjaxFormComponentUpdatingBehavior。请参阅 Javadoc:
我正在尝试使用 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);
您应该使用 AjaxFormChoiceComponentUpdatingBehavior 而不是 AjaxFormComponentUpdatingBehavior。请参阅 Javadoc: