在ajax之前执行actionListener?

时间:2012-10-05 13:11:30

标签: java ajax jsf

如何在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")
    }
}

systout是:

in: ajax
in: actionListener
in: action

0 个答案:

没有答案