a4j:support component
:
<h:selectOneRadio value="#{myBean.myValue}" ...>
...
<a4j:support event="onclick" action="#{myBean.doSomething}"/>
</h:selectOneRadio>
在Java代码中:
public String doSomething() {
// Your code goes here...
...
// Now, we move to the new page.
return "some-outcome";
}
但是,如果您不能(或不想)添加新库,可以使用旧方法执行此操作:
<h:selectOneRadio value="#{myBean.myValue}" ... onclick="this.form.submit();" valueChangeListener="#{myBean.doSomething}">
...
</h:selectOneRadio>
在该方法中,您可以创建要执行的导航规则:
public void doSomething(ValueChangeEvent evt) {
// Your code goes here...
...
// Now, we move to another page...
FacesContext context = FacesContext.getCurrentInstance();
NavigationHandler navigation = context.getApplication().getNavigationHandler();
navigation.handleNavigation(context, "", "some-outcome");
}
其中一些结果是在你脸上的导航规则中定义的结果-配置.xml.