问题
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