What is the execution order of those?
Here is a question about possible f:event
event names: List of JSF 2 events?
preRenderComponent
preRenderView
postAddToView
preValidate
postValidate
I want to check if a User is saved in a session bean is logged in and if not redirect to the login site, which needs to occur before view-param conversion phase since the used converter depends on the logged in User. 'preValidate' seems to take place after conversion and so I need an earlier event.
<f:event type="preRenderView" listener="#{beanA.checkLoggedIn()}"/>
<f:viewParam name="param" value="#{beanB.param}" converter="#{beanB.converter}" required="true"/>
I could have put 'checkLoggedIn()' in 'beanB' too, but tried to use a separate request scoped bean just for the check so that I could reuse it easily.
What is the execution order of those?
postAddToView
runs right after the component is added to view during view build time (which is usually during restore view phase, but can also be during render response phase, e.g. navigation).preValidate
runs right before the component is to be validated (which is usually during validations phase, but can also be apply request values phase if immediate="true"
).postValidate
runs right after the component is been validated (which is usually during validations phase, but can also be apply request values phase if immediate="true"
).preRenderView
runs right before the view is rendered during render response phase.preRenderComponent
runs right before the component is rendered during render response phase.Click the links to see detailed description in javadoc introduction.
I want to check if a User is saved in a session bean is logged in and if not redirect to the login site, which needs to occur before view-param conversion phase since the used converter depends on the logged in User. 'preValidate' seems to take place after conversion and so I need an earlier event.
You should use a simple servlet filter for this, not a JSF event. I've posted several examples before:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With