如何在完成命令按钮操作后调用JavaScript函数?
我正在使用JSF 1.0。
答案 0 :(得分:4)
让JSF条件下呈现所需的脚本。
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>
与
private boolean submitted;
public void submit() {
// ...
submitted = true;
}
public boolean isSubmitted() {
return submitted;
}