Mojarra 2.1.14 flash scope messages and redirect to different path

流过昼夜 提交于 2019-12-06 10:17:54
BalusC

i just used to call an init method that does sets message and redirects but again no message appears!! so i don't think PostConstruct will work either..

Indeed, the <f:event type="preRenderView"> is too late to set a flash message. The flash scope can't be created when JSF is currently sitting in render response phase. You basically need to set the flash message before render response phase. In spite of the name preRenderView, this event is actually fired during (the very beginning of) the render response phase.

The @PostConstruct may be on time, provided that it's not been called during render response. This however won't work very well together with <f:viewParam>.

To fix this, as you're using OmniFaces already, just use <f:event type="postInvokeAction">.

<f:metadata>
    <f:viewParam name="some" value="#{bean.some}" />
    <f:event type="postInvokeAction" listener="#{bean.init}" />
</f:metadata>

See also:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!