JSF-Spring

de.mindmatters.faces.context
Class FacesContextImpl

java.lang.Object
  extended by javax.faces.context.FacesContext
      extended by de.mindmatters.faces.context.FacesContextImpl

public final class FacesContextImpl
extends FacesContext

FacesContext contains all of the per-request state information related to the processing of a single JavaServer 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 servlet container executing this web application utilizes for the processing of this request.

Note: copied from FacesContext docs.

Author:
Andreas Kuhrwahl

Field Summary
protected  org.apache.commons.logging.Log logger
          For logging.
 
Constructor Summary
FacesContextImpl(ExternalContext externalContext)
          Constructs a FacesContext with the given ExternalContext externalContext.
 
Method Summary
 void addMessage(java.lang.String clientId, FacesMessage message)
          

Append a FacesMessage to the set of messages associated with the specified client identifier, if clientId is not null.

 Application getApplication()
          

Return the Application instance associated with this web application.

 java.util.Iterator getClientIdsWithMessages()
          

Return an Iterator over the client identifiers for which at least one FacesMessage has been queued.

 ExternalContext getExternalContext()
          

Return the ExternalContext instance for this FacesContext instance.

 FacesMessage.Severity getMaximumSeverity()
          

Return the maximum severity level recorded on any FacesMessages that has been queued, whether or not they are associated with any specific UIComponent.

 java.util.Iterator getMessages()
          

Return an Iterator over the FacesMessages that have been queued, whether or not they are associated with any specific client identifier.

 java.util.Iterator getMessages(java.lang.String clientId)
          

Return an Iterator over the FacesMessages that have been queued that are associated with the specified client identifier (if clientId is not null), or over the FacesMessages that have been queued that are not associated with any specific client identifier (if clientId is null).

 RenderKit getRenderKit()
          

Return the RenderKit instance for the render kit identifier specified on our UIViewRoot, if there is one.

 boolean getRenderResponse()
          

Return true if the renderResponse() method has been called for the current request.

 boolean getResponseComplete()
          

Return true if the responseComplete() method has been called for the current request.

 ResponseStream getResponseStream()
          

Return the ResponseStream to which components should direct their binary output.

 ResponseWriter getResponseWriter()
          

Return the ResponseWriter to which components should direct their character-based output.

 UIViewRoot getViewRoot()
          

Return the root component that is associated with the this request.

 void release()
          

Release any resources associated with this FacesContext instance.

 void renderResponse()
          

Signal the JavaServer 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.

 void responseComplete()
          

Signal the JavaServer 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.

 void setResponseStream(ResponseStream responseStream)
          

Set the ResponseStream to which components should direct their binary output.

 void setResponseWriter(ResponseWriter responseWriter)
          

Set the ResponseWriter to which components should direct their character-based output.

 void setViewRoot(UIViewRoot viewRoot)
          

Set the root component that is associated with this request.

 
Methods inherited from class javax.faces.context.FacesContext
getCurrentInstance, setCurrentInstance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final org.apache.commons.logging.Log logger
For logging.

Constructor Detail

FacesContextImpl

public FacesContextImpl(ExternalContext externalContext)
Constructs a FacesContext with the given ExternalContext externalContext.

Parameters:
externalContext - usually a fake context
See Also:
ServletExternalContextFake
Method Detail

getApplication

public Application getApplication()

Return the Application instance associated with this web application.

Specified by:
getApplication in class FacesContext

getClientIdsWithMessages

public java.util.Iterator getClientIdsWithMessages()

Return an Iterator over the client identifiers for which at least one FacesMessage has been queued. If there are no such client identifiers, an empty Iterator is returned. If any messages have been queued that were not associated with any specific client identifier, a null value will be included in the iterated values.

Specified by:
getClientIdsWithMessages in class FacesContext

getExternalContext

public ExternalContext getExternalContext()

Return the ExternalContext instance for this FacesContext instance.

Specified by:
getExternalContext in class FacesContext

getMaximumSeverity

public FacesMessage.Severity getMaximumSeverity()

Return the maximum severity level recorded on any FacesMessages that has been queued, whether or not they are associated with any specific UIComponent. If no such messages have been queued, return null.

Specified by:
getMaximumSeverity in class FacesContext

getMessages

public java.util.Iterator getMessages()

Return an Iterator over the FacesMessages that have been queued, whether or not they are associated with any specific client identifier. If no such messages have been queued, return an empty Iterator.

Specified by:
getMessages in class FacesContext

getMessages

public java.util.Iterator getMessages(java.lang.String clientId)

Return an Iterator over the FacesMessages that have been queued that are associated with the specified client identifier (if clientId is not null), or over the FacesMessages that have been queued that are not associated with any specific client identifier (if clientId is null). If no such messages have been queued, return an empty Iterator.

Specified by:
getMessages in class FacesContext
Parameters:
clientId - The client identifier for which messages are requested, or null for messages not associated with any client identifier

getRenderKit

public RenderKit getRenderKit()

Return the RenderKit instance for the render kit identifier specified on our UIViewRoot, if there is one. If there is no current UIViewRoot, if the UIViewRoot does not have a specified renderKitId, or if there is no RenderKit for the specified identifier, return null instead.

Specified by:
getRenderKit in class FacesContext

getRenderResponse

public boolean getRenderResponse()

Return true if the renderResponse() method has been called for the current request.

Specified by:
getRenderResponse in class FacesContext

getResponseComplete

public boolean getResponseComplete()

Return true if the responseComplete() method has been called for the current request.

Specified by:
getResponseComplete in class FacesContext

addMessage

public void addMessage(java.lang.String clientId,
                       FacesMessage message)

Append a FacesMessage to the set of messages associated with the specified client identifier, if clientId is not null. If clientId is null, this FacesMessage is assumed to not be associated with any specific component instance.

Specified by:
addMessage in class FacesContext
Parameters:
clientId - The client identifier with which this message is associated (if any)
message - The message to be appended

release

public void release()

Release any resources associated with this FacesContext instance. Faces implementations may choose to pool instances in the associated FacesContextFactory to avoid repeated object creation and garbage collection. After release() is called on a FacesContext instance (until the FacesContext instance has been recycled by the implementation for re-use), calling any other methods will cause an IllegalStateException to be thrown.

The implementation must call FacesContext.setCurrentInstance(javax.faces.context.FacesContext) passing null to remove the association between this thread and this dead FacesContext instance.

Specified by:
release in class FacesContext

renderResponse

public void renderResponse()

Signal the JavaServer 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.

Specified by:
renderResponse in class FacesContext

responseComplete

public void responseComplete()

Signal the JavaServer 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.

Specified by:
responseComplete in class FacesContext

getResponseStream

public ResponseStream getResponseStream()

Return the ResponseStream to which components should direct their binary output. Within a given response, components can use either the ResponseStream or the ResponseWriter, but not both.

Specified by:
getResponseStream in class FacesContext

setResponseStream

public void setResponseStream(ResponseStream responseStream)

Set the ResponseStream to which components should direct their binary output.

Specified by:
setResponseStream in class FacesContext
Parameters:
responseStream - The new ResponseStream for this response

getResponseWriter

public ResponseWriter getResponseWriter()

Return the ResponseWriter to which components should direct their character-based output. Within a given response, components can use either the ResponseStream or the ResponseWriter, but not both.

Specified by:
getResponseWriter in class FacesContext

setResponseWriter

public void setResponseWriter(ResponseWriter responseWriter)

Set the ResponseWriter to which components should direct their character-based output.

Specified by:
setResponseWriter in class FacesContext
Parameters:
responseWriter - The new ResponseWriter for this response

getViewRoot

public UIViewRoot getViewRoot()

Return the root component that is associated with the this request.

Specified by:
getViewRoot in class FacesContext

setViewRoot

public void setViewRoot(UIViewRoot viewRoot)

Set the root component that is associated with this request. This method can only be called by the application handler (or a class that the handler calls), and only during the Invoke Application phase of the request processing lifecycle.

Specified by:
setViewRoot in class FacesContext
Parameters:
viewRoot - The new component UIViewRoot component

JSF-Spring

Copyright © 2006 mindmatters GmbH & Co. KG