Calling javascript on complete of commandbutton action

后端 未结 1 1420
[愿得一人]
[愿得一人] 2021-01-29 02:06

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

I\'m using JSF 1.0.

相关标签:
1条回答
  • 2021-01-29 02:50

    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;
    }
    
    0 讨论(0)
提交回复
热议问题