When a particular method in my managed bean gets called, I want to know whether I’m in the Restore View phase of the JSF Lifecycle. How can I do this?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you’re already on JSF 2.0, then you can check it using
FacesContext#getCurrentPhaseId():But if you’re still on JSF 1.x yet, then your best resort is using a
PhaseListenerwhich listens onPhaseId.RESTORE_VIEW, sets a flag/toggle/token in the request scope duringbeforePhase()and removes the it duringafterPhase(). Let the bean’s getter method check its presence in the request scope then.That said, what exactly do you need it for? I’ve never had the need for such a functional requirement. Isn’t the bean’s constructor or an
@PostConstructannotated method probably a better place to do initialization stuff like this?