If you are already using JSF 2.0, you can check it using FacesContext#getCurrentPhaseId() :
if (FacesContext.getCurrentInstance().getCurrentPhaseId() == PhaseId.RESTORE_VIEW) {
But if you're still on JSF 1.x, then your best resort uses the PhaseListener , which listens for PhaseId.RESTORE_VIEW , sets the / toggle / token flag in the request area during beforePhase() and removes it during afterPhase() . Let the getter bean method check its presence in the request area.
So what exactly do you need it for? I never had the need for such a functional requirement. Is the bean constructor or the annotated @PostConstruct method probably better to use such things to initialize?
source share