문제

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

I'm using JSF 1.0.

도움이 되었습니까?

해결책

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;
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top