Question

HI,

I need clarification on implementing the PhaseListener class. The following is the two different overriding implementation for the PhaseListener.getPhaseId

@Override
public PhaseId getPhaseId() {       
    return PhaseId.ANY_PHASE;
}

and

@Override
public PhaseId getPhaseId() {       
    return PhaseId.RESTORE_VIEW;
}

What could be the significant difference in those two implementations?. What will be the impact?

Was it helpful?

Solution

As stated in the PhaseListener#getPhaseId() javadoc, this indicates for which PhaseId the current PhaseListener implementation should execute the implemented beforePhase() and afterPhase() methods. In the first example, they will be executed on any phase and in the second example, they will be executed in the RESTORE_VIEW phase only (which is the firstmost phase of the JSF lifecycle).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top