My JSF Books/Videos My JSF Tutorials OmniFaces/JSF PPTs
JSF 2.3 Tutorial
JSF Caching Tutorial
JSF Navigation Tutorial
JSF Scopes Tutorial
JSF Page Author Beginner's Guide
OmniFaces 2.3 Tutorial Examples
OmniFaces 2.2 Tutorial Examples
JSF Events Tutorial
OmniFaces Callbacks Usages
JSF State Tutorial
JSF and Design Patterns
JSF 2.3 New Features (2.3-m04)
Introduction to OmniFaces
25+ Reasons to use OmniFaces in JSF
OmniFaces Validators
OmniFaces Converters
JSF Design Patterns
Mastering OmniFaces
Reusable and less-verbose JSF code

My JSF Resources ...

Java EE Guardian
Member of JCG Program
Member MVB DZone
Blog curated on ZEEF
OmniFaces is an utility library for JSF, including PrimeFaces, RichFaces, ICEfaces ...

[OmniFaces Utilities] - Find the right JSF OmniFaces 2 utilities methods/functions

Search on blog

Petition by Java EE Guardians

Twitter

miercuri, 8 aprilie 2015

[OmniFaces utilities (2.0)] Check if we're currently in the Render Response phase


[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;
}

Niciun comentariu :

Trimiteți un comentariu

JSF BOOKS COLLECTION

Postări populare

OmniFaces/JSF Fans

Follow by Email

Visitors Starting 4 September 2015

Locations of Site Visitors