如何在 ajax 请求之前执行 actionListener?
<h:commandButton actionListener=.. action=..>
<f:ajax render="test">
</h:commandButton>
执行顺序是:
test
actionListener
action
我可以更改什么以便在 f:ajax 之前执行 actionListener 方法?
完整示例:
<h:form>
<h:commandButton value="test" actionListener="#{bean.toggleProgress}" action="#{bean.do()}" >
<f:ajax execute="@form" render="progress" />
</h:commandButton>
<h:panelGroup id="progress" >
<h:outputText rendered="#{bean.progress}" />
</h:panelGroup>
</h:form>
class Bean {
private progress = false;
public boolean isProgress() {
System.out.println("in: ajax")
return progress;
}
public toggleProgress(ActionEvent e) {
System.out.println("in: actionListener")
progress = true;
}
public void do() {
System.out.println("in: action")
}
}
系统输出是:
in: ajax
in: actionListener
in: action