[OmniFaces utilities] The
isRenderResponse() method returns true if we're currently in the Render Response phase. This explicitly checks the current phase ID instead of FacesContext#getRenderResponse() as the latter may unexpectedly return false during a GET request when <f:viewParam> is been used.Method:
See also: Faces#getContext()
Usage:
The Faces#isRenderResponse()
is an useful method when the snippet of code that follows must be executed only
in Render Response phase, or in any phase, except the Render Response phase:
import
org.omnifaces.util.Faces;
...
boolean isRR =
Faces.isRenderResponse();
if(isRR){
// JSF lifecycle is in Render Response phase
} else {
// JSF
lifecycle is not in Render Response phase
}
Based on Faces#isRenderResponse()
implementation, you can write a method for each JSF phase. For example, you can
write an isProcessValidations()
method, as below:
public
static boolean isProcessValidations(FacesContext context) {
return context.getCurrentPhaseId() == PhaseId.PROCESS_VALIDATIONS;
}
Or, even a
generic method (pass it the JSF PhaseId to be checked):
public
static boolean isPhase(FacesContext context, PhaseId phaseId) {
return context.getCurrentPhaseId() ==
phaseId;
}






Arrays
Converters
JSF 2 Tutorials at www.mkyong.com
JavaServer Faces (JSF) Tutorial 


















Niciun comentariu :
Trimiteți un comentariu