是否可以禁用 f:event type=“preRenderView"?回传的听众? [英] Is it possible to disable f:event type="preRenderView" listener on postback?
本文介绍了是否可以禁用 f:event type=“preRenderView"?回传的听众?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在回发时禁用"触发此操作?
Is it possible to "disable" triggering of this action when doing postback?
<f:metadata>
<f:event listener="#{defaultNewQuestionHandler.init}" type="preRenderView" />
</f:metadata>
推荐答案
这在
中是不可能的.您需要手动检查 FacesContext#isPostback()
在监听器方法中.
That's not possible with <f:event>
. You need to manually check FacesContext#isPostback()
inside the listener method.
public void init() {
if (!FacesContext.getCurrentInstance().isPostback()) {
// ...
}
}
在即将到来的 JSF 2.2
标签中,它应该替换这个
"解决方法",但是可以使用 onPostback
属性:
In the upcoming JSF 2.2 <f:viewAction>
tag, which is supposed to replace this <f:event type="preRenderView">
"workaround", it will however be possible with the onPostback
attribute:
<f:viewAction action="#{defaultNewQuestionHandler.init}" onPostback="false" />
JSF 2.2 的快照版本已经可用.
Snapshot releases of JSF 2.2 are already available.
这篇关于是否可以禁用 f:event type=“preRenderView"?回传的听众?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文