and*_*Pat 3 java wicket radio-button
如何在检票口中"实时"选择单选按钮?我的意思是,如果我有一个带有两个选项A和B的单选按钮,我想在按钮上添加一个ajax行为(在更改时,在更新时,无论有什么用),这样如果我选择A它会在页面中发生某些事情,如果我选择B发生了别的事情.你能帮助我吗?
Xav*_*ica 10
只需添加一个AjaxFormChoiceComponentUpdatingBehavior到RadioChoice:
RadioChoice radioChoice = new RadioChoice("myRadio", choiceList);
radioChoice.add( new AjaxFormChoiceComponentUpdatingBehavior("onchange") {
protected void onUpdate(AjaxRequestTarget target) {
// Ajax actions here
System.out.println("The selected value is " + getComponent().getDefaultModelObjectAsString()));
}
} );
form.add(radioChoice);
Run Code Online (Sandbox Code Playgroud)
RadioChoice遗嘱的模型在执行时已经更新onUpdate.请记住添加到target要通过AJAX刷新的所有组件(当然还要设置setOutputMarkupId(true)为它们).
有一个与你在找什么的源代码在线例子在这里.相关的源代码文件就是这个.