是否可以禁用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>
推荐答案
对于<f:event>
,这是不可能的.您需要手动检查 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 <f:viewAction>
标记中,该标记应该替换此<f:event type="preRenderView">
解决方法",但是可以使用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屋!
查看全文