Calling javascript on complete of commandbutton ac

2019-03-06 02:28发布

How can I call a JavaScript function after completion of command button action?

I'm using JSF 1.0.

1条回答
Fickle 薄情
2楼-- · 2019-03-06 03:05

Just let JSF conditonally render the desired script.

E.g.

<h:form>
    <h:commandButton value="Submit" action="#{bean.submit}" />
    <h:panelGroup rendered="#{bean.submitted}">
        <script>alert('Form was submitted!');</script>
    </h:panelGroup>
</h:form>

with

private boolean submitted;

public void submit() {
    // ...
    submitted = true;
}

public boolean isSubmitted() {
    return submitted;
}
查看更多
登录 后发表回答