Calling javascript on complete of commandbutton action

倾然丶 夕夏残阳落幕 提交于 2019-12-04 05:39:45

问题


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

I'm using JSF 1.0.


回答1:


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;
}


来源:https://stackoverflow.com/questions/21680023/calling-javascript-on-complete-of-commandbutton-action

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!