PF 3.5.10, Mojarra 2.1.21, Omnifaces 1.5
How to call special init()-method of some (CDI)SessionScoped bean before I load a .xhtml JSF page ? Now I call init() if user select the page from site menu (with p:menutitem
). But what to do if the user use browser address line to type url directly?
Edit: my.xhtml
:
<ui:define template="/mytemp.xhtml">
<f:event type="preRenderView" listener="#{mybean.init()}" />
<h:form>
<p:commandButton update="@form" ... />
</h:form>
</ui:define>
If I do it that way the init() will be called on every update (i.e. on every postback to a server),in example on every click of commandButton. So I can not use your proposal.
Edit 2: Thank you Luiggi Mendoza, and BalusC! In addtion to solution from Luiggi Mendoza, as in comments stated the Omnifaces 1.6 will be have ViewScope also.