本文介绍了在窗口卸载时从javascript调用a4j:commandButton的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法调用 a4j:commandButton
点击窗口卸载。我的jsf代码在这里
I am not able to call a4j:commandButton
click on window unload. my jsf code is here
第一个 javascript
其中我有窗口卸载方法,我已调用按钮单击该功能。
1st the javascript
in which i have window unload method and i have called button click in that function.
<script type="text/javascript">
window.onbeforeunload = function() {
document.getElementById('pForm:closeTime').click();
}
</script>
第二个我隐藏了 a4j:commandButton
in正文
2nd i have hidden a4j:commandButton
in body
<h:form id="pForm">
<a4j:commandButton id="closeTime" value="" action="#{controller.update}" oncomplete="javascript:window.close()" style="visibility:hidden;display:none" </a4j:commandButton>
</h:form>
当窗口关闭时,此控制器未被调用。请帮帮我!!!
when window is closed this controller is not getting called. Help me out in this !!!
推荐答案
使用 jsFunction $ c $更清洁c>为此:
<script type="text/javascript">
window.onbeforeunload = function() {
closeTime();
}
</script>
<h:form id="pForm">
<a4j:jsFunction name="closeTime"
action="#{controller.update}"
oncomplete="window.close()"/>
</h:form>
这篇关于在窗口卸载时从javascript调用a4j:commandButton的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!