JSF provides
several objects related to the current request and environment. EL exposes
these objects (known as implicit objects) that can be
accessed at runtime in a Facelet, servlets, or backing bean—these objects are
accessible through value expressions and are managed by the container. Beside
the JSF 2.2 implicit objects, JSF 2.3 will allow developers to
access the ExternalContext via an implicit object. Basically, we have:
JSF 2.2 - access ExternalContext via static method
ExternalContext
externalContext = FacesContext.getCurrentInstance().getExternalContext();
OmniFaces static shortcut for ExternalContext
ExternalContext
externalContext = Faces.getExternalContext();
JSF 2.3 - ExternalContext implicit object
#{externalContext}
JSF 2.3 CDI producer method for ExternalContext:
@Inject
private
ExternalContext externalContext;
Check out
the entire list of JSF 2.3 CDI producer methods:
Niciun comentariu :
Trimiteți un comentariu