Understanding the PhaseListener.getPhaseId Function

Hi

I need to clarify how to implement the PhaseListener class. Below are two different overriding implementations for PhaseListener.getPhaseId

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

and

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

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

+3
source share
1 answer

As stated in PhaseListener#getPhaseId()javadoc, this means that the PhaseIdcurrent PhaseListenerimplementation must execute the implemented beforePhase()and afterPhase(). In the first example, they will be executed in any phase, and in the second example, they will be executed only in the phase RESTORE_VIEW(which is the first phase of the JSF life cycle itself).

+5
source

Source: https://habr.com/ru/post/1787078/


All Articles