FacesContext contains all of the per-request state information related to the processing of a single Jakarta Faces request, and the rendering of the corresponding response. It is passed to, and potentially modified by, each phase of the request processing lifecycle.
A FacesContext
instance is associated with a particular request at the beginning of request processing, by a
call to the getFacesContext()
method of the FacesContextFactory
instance associated with the
current web application. The instance remains active until its release()
method is called, after which
no further references to this instance are allowed. While a FacesContext
instance is active, it must not be
referenced from any thread other than the one upon which the Jakarta Servlet container executing this web application
utilizes for the processing of this request.
A FacesContext can be injected into a request scoped bean using @Inject FacesContext facesContext;
Modifier and Type | Field and Description |
---|---|
private Map | |
private PhaseId | |
private FacesContext | |
private static ConcurrentHashMap | |
private static ThreadLocal | instance
The |
private boolean | |
private PartialViewContext | |
private boolean | |
private static ConcurrentHashMap |
Access | Constructor and Description |
---|---|
public |
Modifier and Type | Method and Description |
---|---|
public abstract void | addMessage(String
The client identifier with which this message is associated (if any) clientId, FacesMessage The message to be appended message)
Append a |
public abstract Application | Returns: theApplication instance associated with this web application.
Return the |
public Map | Returns: mutableMap representing the attributes associated wth this FacesContext instance.
Return a mutable |
public abstract Iterator | Returns: theIterator over the client identifiers for which at least one
jakarta.faces.application.FacesMessage has been queued.
Return an |
public static FacesContext | Returns: the instance ofFacesContext .
Return the |
public PhaseId | Returns: the current phase id.
Return the value last set on this |
public ELContext | Returns: instance ofELContext .
Return the |
public ExceptionHandler | Returns: instance ofExceptionHandler .
Return the |
public abstract ExternalContext | Returns: instance ofExternalContext
Return the |
public abstract Lifecycle | Returns: instance ofLifecycle
Return the |
public abstract FacesMessage. | Returns: the maximum severity level.
Return the maximum severity level recorded on any |
public List | Returns: an immutableList which is effectively a snapshot of the messages present at the time of
invocation.
Like |
public List | Returns: an immutableList which is effectively a snapshot of the messages present at the time of
invocation.the client id of a component. clientId)
Like |
public abstract Iterator | Returns: Iterator over the FacesMessage s that have been queued.
Return an |
public abstract Iterator | Returns: Iterator over the FacesMessage s.The client identifier for which messages are requested, or clientId)null for messages not
associated with any client identifier
Return an |
public char | Returns: the separator char.
Return the result of calling |
public PartialViewContext | Returns: the instance ofPartialViewContext for this request.
Return the |
public abstract RenderKit | Returns: instance ofRenderKit associated with the UIViewRoot .
Return the |
public abstract boolean | Returns: flag indicating whether therenderResponse() has been called.
Return |
public List | Returns: the list of resource library contracts.Return the list of resource library contracts that have been calculated to be appropriate for use with this view, or an empty list if there are no such resource library contracts. |
public abstract boolean | Returns: the boolean indicating whetherresponseComplete() method has been called.
Return |
public abstract ResponseStream | Returns: ResponseStream instance.
Return the |
public abstract ResponseWriter | Returns: ResponseWriter instance.
Return the |
public abstract UIViewRoot | Returns: UIViewRoot instance.Return the root component that is associated with the this request. |
public boolean | Returns: the boolean indicating whether this request is a post one.
This utility method simply returns the result of
|
public boolean | Returns: true if events should be published, otherwise false Returns a flag indicating whether or not the runtime should publish events when asked to do so. |
public boolean | Returns: boolean indicating whether the application has the same stage.the stage)ProjectStage to check
Return |
public boolean | Returns: true if the resources have been released.
Return a flag indicating if the resources associated with this |
public boolean | Returns: boolean indicating if thevalidationFailed() method has been called for the current request
Return |
public abstract void | |
public abstract void | renderResponse()
Signal the Jakarta Faces implementation that, as soon as the current phase of the request processing lifecycle has been completed, control should be passed to the Render Response phase, bypassing any phases that have not been executed yet. |
public abstract void | responseComplete()
Signal the Jakarta Faces implementation that the HTTP response for this request has already been generated (such as an HTTP redirect), and that the request processing lifecycle should be terminated as soon as the current phase is completed. |
protected static void | setCurrentInstance(FacesContext
The context)FacesContext instance for the current thread, or null if this thread no
longer has a FacesContext instance.
Set the |
public void | setCurrentPhaseId(PhaseId
The currentPhaseId)jakarta.faces.event.PhaseId for the current phase.The implementation must call this method at the earliest possble point in time after entering into a new phase in the request processing lifecycle. |
public void | setExceptionHandler(ExceptionHandler
the exceptionHandler)ExceptionHandler for this request.
Set the |
public void | setProcessingEvents(boolean
flag indicating events should be processed or not processingEvents)
Allows control of wheter or not the runtime will publish events when
|
public void | setResourceLibraryContracts(List<String>
The new contracts to be returned, as an immutable contracts)List . from a subsequent call to
getResourceLibraryContracts .Set the resource library contracts calculated as valid to use with this view. |
public abstract void | setResponseStream(ResponseStream
The new ResponseStream for this response responseStream)
Set the |
public abstract void | setResponseWriter(ResponseWriter
The new ResponseWriter for this response responseWriter)
Set the |
public abstract void | setViewRoot(UIViewRoot
The new component root)UIViewRoot componentSet the root component that is associated with this request. |
public void | validationFailed()
Sets a flag which indicates that a conversion or validation error occurred while processing the inputs. |
attributesForInvalidFactoryConstruction | back to summary |
---|---|
private Map<Object, Object> attributesForInvalidFactoryConstruction |
currentPhaseIdForInvalidFactoryConstruction | back to summary |
---|---|
private PhaseId currentPhaseIdForInvalidFactoryConstruction |
defaultFacesContext | back to summary |
---|---|
private FacesContext defaultFacesContext |
initContextServletContext | back to summary |
---|---|
private static ConcurrentHashMap<K, V> initContextServletContext |
instance | back to summary |
---|---|
private static ThreadLocal<FacesContext> instance
The |
isCreatedFromValidFactory | back to summary |
---|---|
private boolean isCreatedFromValidFactory |
partialViewContextForInvalidFactoryConstruction | back to summary |
---|---|
private PartialViewContext partialViewContextForInvalidFactoryConstruction |
processingEvents | back to summary |
---|---|
private boolean processingEvents |
threadInitContext | back to summary |
---|---|
private static ConcurrentHashMap<K, V> threadInitContext |
FacesContext | back to summary |
---|---|
public FacesContext() Default constructor. This looks at the callstack to see if we're created from a factory. |
addMessage | back to summary |
---|---|
public abstract void addMessage(String clientId, FacesMessage message)
Append a
|
getApplication | back to summary |
---|---|
public abstract Application getApplication()
Return the
It is valid to call this method during application startup or shutdown. If called during application startup or
shutdown, returns the correct current
|
getAttributes | back to summary |
---|---|
public Map
Return a mutable
The
The default implementation throws
|
getClientIdsWithMessages | back to summary |
---|---|
public abstract Iterator
Return an
|
getCurrentInstance | back to summary |
---|---|
public static FacesContext getCurrentInstance()
Return the
|
getCurrentPhaseId | back to summary |
---|---|
public PhaseId getCurrentPhaseId()
Return the value last set on this
|
getELContext | back to summary |
---|---|
public ELContext getELContext()
Return the
|
getExceptionHandler | back to summary |
---|---|
public ExceptionHandler getExceptionHandler()
Return the
|
getExternalContext | back to summary |
---|---|
public abstract ExternalContext getExternalContext()
Return the
It is valid to call this method during application startup or shutdown. If called during application startup or
shutdown, this method returns an
|
getLifecycle | back to summary |
---|---|
public abstract Lifecycle getLifecycle()
Return the
|
getMaximumSeverity | back to summary |
---|---|
public abstract FacesMessage.
Return the maximum severity level recorded on any
|
getMessageList | back to summary |
---|---|
public List
Like
The default implementation throws
|
getMessageList | back to summary |
---|---|
public List
Like
The default implementation throws
|
getMessages | back to summary |
---|---|
public abstract Iterator
Return an
|
getMessages | back to summary |
---|---|
public abstract Iterator
Return an
|
getNamingContainerSeparatorChar | back to summary |
---|---|
public char getNamingContainerSeparatorChar()
Return the result of calling
|
getPartialViewContext | back to summary |
---|---|
public PartialViewContext getPartialViewContext()
Return the
|
getRenderKit | back to summary |
---|---|
public abstract RenderKit getRenderKit()
Return the
|
getRenderResponse | back to summary |
---|---|
public abstract boolean getRenderResponse()
Return
|
getResourceLibraryContracts | back to summary |
---|---|
public List Return the list of resource library contracts that have been calculated to be appropriate for use with this view, or an empty list if there are no such resource library contracts. The list returned by this method must be immutable. For backward compatibility with implementations of the specification prior to when this method was introduced, an implementation is provided that returns an empty list. Implementations compliant with the version in which this method was introduced must implement this method as specified.
|
getResponseComplete | back to summary |
---|---|
public abstract boolean getResponseComplete()
Return
|
getResponseStream | back to summary |
---|---|
public abstract ResponseStream getResponseStream()
Return the
|
getResponseWriter | back to summary |
---|---|
public abstract ResponseWriter getResponseWriter()
Return the
|
getViewRoot | back to summary |
---|---|
public abstract UIViewRoot getViewRoot() Return the root component that is associated with the this request.
It is valid to call this method during application startup or shutdown. If called during application startup or
shutdown, this method returns a new
|
isPostback | back to summary |
---|---|
public boolean isPostback()
This utility method simply returns the result of
The default implementation throws
|
isProcessingEvents | back to summary |
---|---|
public boolean isProcessingEvents() Returns a flag indicating whether or not the runtime should publish events when asked to do so.
|
isProjectStage | back to summary |
---|---|
public boolean isProjectStage(ProjectStage stage)
Return
|
isReleased | back to summary |
---|---|
public boolean isReleased()
Return a flag indicating if the resources associated with this
|
isValidationFailed | back to summary |
---|---|
public boolean isValidationFailed()
Return
|
release | back to summary |
---|---|
public abstract void release()
Release any resources associated with this
If a call was made to
The implementation must call
|
renderResponse | back to summary |
---|---|
public abstract void renderResponse() Signal the Jakarta Faces implementation that, as soon as the current phase of the request processing lifecycle has been completed, control should be passed to the Render Response phase, bypassing any phases that have not been executed yet.
|
responseComplete | back to summary |
---|---|
public abstract void responseComplete() Signal the Jakarta Faces implementation that the HTTP response for this request has already been generated (such as an HTTP redirect), and that the request processing lifecycle should be terminated as soon as the current phase is completed.
|
setCurrentInstance | back to summary |
---|---|
protected static void setCurrentInstance(FacesContext context)
Set the
|
setCurrentPhaseId | back to summary |
---|---|
public void setCurrentPhaseId(PhaseId currentPhaseId) The implementation must call this method at the earliest possble point in time after entering into a new phase in the request processing lifecycle.
|
setExceptionHandler | back to summary |
---|---|
public void setExceptionHandler(ExceptionHandler exceptionHandler)
Set the
|
setProcessingEvents | back to summary |
---|---|
public void setProcessingEvents(boolean processingEvents)
Allows control of wheter or not the runtime will publish events when
|
setResourceLibraryContracts | back to summary |
---|---|
public void setResourceLibraryContracts(List<String> contracts)
Set the resource library contracts calculated as valid to use with this view. The implementation must copy the
contents of the incoming
|
setResponseStream | back to summary |
---|---|
public abstract void setResponseStream(ResponseStream responseStream)
Set the
|
setResponseWriter | back to summary |
---|---|
public abstract void setResponseWriter(ResponseWriter responseWriter)
Set the
|
setViewRoot | back to summary |
---|---|
public abstract void setViewRoot(UIViewRoot root) Set the root component that is associated with this request. This method can be called by the application handler (or a class that the handler calls), during the Invoke Application phase of the request processing lifecycle and during the Restore View phase of the request processing lifecycle (especially when a new root component is created). In the present version of the specification, implementations are not required to enforce this restriction, though a future version of the specification may require enforcement.
If the current
|
validationFailed | back to summary |
---|---|
public void validationFailed()
Sets a flag which indicates that a conversion or validation error occurred while processing the inputs. Inputs
consist of either page parameters or form bindings. This flag can be read using
|