Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is FacesContext used for?

What is FacesContext used for?

And where exactly is it implemented?

like image 642
meenus Avatar asked May 03 '11 05:05

meenus


People also ask

What does FacesContext getCurrentInstance () do?

getCurrentInstance. Return the FacesContext instance for the request that is being processed by the current thread.

What is external context in JSF?

public abstract class ExternalContext extends Object. This class allows the Faces API to be unaware of the nature of its containing application environment. In particular, this class allows JavaServer Faces based appications to run in either a Servlet or a Portlet environment.


1 Answers

Quote from chapter 6.1 of JSF 2.0 specification:

FacesContext

JSF defines the javax.faces.context.FacesContext abstract base class for representing all of the contextual information associated with processing an incoming request, and creating the corresponding response.

A FacesContext instance is created by the JSF implementation, prior to beginning the request processing lifecycle, by a call to the getFacesContext method of FacesContextFactory, as described in Section 6.6 “FacesContextFactory”.

When the request processing lifecycle has been completed, the JSF implementation will call the release method, which gives JSF implementations the opportunity to release any acquired resources, as well as to pool and recycle FacesContext instances rather than creating new ones for each request.

It is specified in class javax.faces.context.FacesContext and in Mojarra implemented in class com.sun.faces.context.FacesContextImpl and in MyFaces implemented in class org.apache.myfaces.context.servlet.FacesContextImpl.

See also:

  • What is the difference between FacesContext and ExternalContext
like image 199
Matt Handy Avatar answered Sep 18 '22 00:09

Matt Handy