JSF:JS重定向不';不适用于h:commandButton onclick事件
从JSF:JS重定向不';不适用于h:commandButton onclick事件,jsf,button,redirect,ajax4jsf,Jsf,Button,Redirect,Ajax4jsf,从a4j:commandLink迁移到h:commandButton问题 本工作案例: <a4j:commandLink event="onclick" onclick="if (!confirm('#{resourceBundle.agreement_cancel_message}')) return false;" oncomplete="window.location.href='menu?agreementId='+ agreementId;"/> 据我所知,我根本无法对
a4j:commandLink
迁移到h:commandButton
问题
本工作案例:
<a4j:commandLink event="onclick" onclick="if (!confirm('#{resourceBundle.agreement_cancel_message}')) return false;" oncomplete="window.location.href='menu?agreementId='+ agreementId;"/>
据我所知,我根本无法对
h:commandButton
使用oncomplete
。页面被刷新,因为输入的默认事件处理程序正在工作
尝试阻止输入的提交行为(返回false;在末尾):
页面被刷新,因为输入的默认事件处理程序正在工作 尝试阻止输入的提交行为(返回false;在末尾):
您需要始终返回false
,以防止按钮的默认操作(提交表单)
您需要始终返回false
,以防止按钮的默认操作(提交表单)
如何说,因为它类似于我们的项目策略-减少a4j:command*usaget这是不可能的,因为您正在通过JS更改当前位置。如何说,因为它类似于我们的项目策略-减少a4j:command*usaget这是不可能的,因为您正在通过JS更改当前位置。
<h:commandButton onclick="if (!confirm('#{resourceBundle.agreement_cancel_message}')) return false;window.location.href='menu?agreementId='+ agreementId;"/>
<h:commandButton onclick="if (!confirm('#{resourceBundle.agreement_cancel_message}')) return false;window.location.href='menu?agreementId='+ agreementId; return false;"/>
<h:commandButton onclick="if(confirm('#{resourceBundle.agreement_cancel_message}'))window.location.href='menu?agreementId='+ agreementId;return false;"/>
<button onclick="if(confirm('#{resourceBundle.agreement_cancel_message}'))window.location.href='menu?agreementId='+ agreementId;return false;"/>