Previous Section  < Day Day Up >  Next Section

D.3 Package javax.faces.context

ExternalContext

An instance of a subclass of this abstract class is available through the FacesContext and provides access to context objects that may vary between environments, such as a servlet and a portlet environment, in an environment-independent way. Classes using the methods only in this class to access the environment should be portable between different container environments.

Synopsis

Class name:

javax.faces.context.ExternalContext

Extends:

None

Implements:

None

Fields


public static final String BASIC_AUTH

The identifier for the basic authentication scheme: BASIC.


public static final String CLIENT_CERT_AUTH

The identifier for the client certification authentication scheme: CLIENT_CERT.


public static final String DIGEST_AUTH

The identifier for the digest authentication scheme: DIGEST.


public static final String FORM_AUTH

The identifier for the form-based authentication scheme: FORM.

Constructors


public ExternalContext()

Creates an instance.

Methods


public abstract void dispatch(String path) throws java.io.IOException

Dispatchs the request to the resource at the specified path to let it generate the response.


public abstract String encodeActionURL(String url)

Returns the provided URL, possibly modified to ensure that it correctly identifies a JSF view. In a servlet environment, the URL is passed through the javax.servlet.http.HttpServletResponse encodeURL() method, which encodes it to include a session ID if needed.


public abstract String encodeNamespace(String name)

Returns the provided name, possibly prefixed with a namespace to ensure it's unique within the context of a particular page. In a servlet environment, the name is returned unmodified.


public abstract String encodeResourceURL(String url)

Returns the provided URL, possibly modified to ensure that it correctly identifies an application resource, such as an image. In a servlet environment, the URL is passed through the javax.servlet.http.HttpServletResponse encodeURL() method, which encodes it to include a session ID if needed.


public abstract java.util.Map getApplicationMap()

Returns a mutable Map representing the application scope, keyed by variable name with Object values.


public abstract String getAuthType()

Returns the name of the authentication scheme used for the current user, or null if the current user isn't authenticated by the container. One of BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, or FORM_AUTH for the standard schemes.


public abstract Object getContext()

Returns the native object representing the environment-specific context. In servlet environment, this is a javax.servlet.ServletContext instance.


public abstract String getInitParameter(String name)

Returns the value of the named application context initialization parameter or null if not found.


public abstract java.util.Map getInitParameterMap()

Returns an immutable Map with all application context initialization parameters, keyed by name with String values.


public abstract String getRemoteUser()

Returns the name of the authenticated user or null if the current user isn't authenticated by the container.


public abstract Object getRequest()

Returns the native object representing the environment-specific request data. In servlet environment, this is a javax.servlet.http.HttpServletRequest instance.


public abstract String getRequestContextPath()

Returns the portion of the request URI that identifies the application context.


public abstract java.util.Map getRequestCookieMap()

Returns an immutable Map with cookies received with the current request, keyed by name with javax.servlet.http.Cookie values.


public abstract java.util.Map getRequestHeaderMap()

Returns an immutable Map with headers for the current request, keyed by name with String values.


public abstract java.util.Map getRequestHeaderValuesMap()

Returns an immutable Map with headers for the current request, keyed by name with String[] values (holding all values for a header).


public abstract java.util.Locale getRequestLocale()

Returns the Locale with the highest preference according to the request data.


public abstract java.util.Iterator getRequestLocales()

Returns an Iterator over all Locale instances in preference order based on the request data.


public abstract java.util.Map getRequestMap()

Returns a mutable Map representing the request scope, keyed by variable name with Object values.


public abstract java.util.Map getRequestParameterMap()

Returns an immutable Map with parameters for the current request, keyed by name with String values.


public abstract java.util.Iterator getRequestParameterNames()

Returns an Iterator over all request parameter names.


public abstract java.util.Map getRequestParameterValuesMap()

Returns an immutable Map with parameters for the current request, keyed by name with String[] values (holding all values for a parameter).


public abstract String getRequestPathInfo()

Returns the portion of the request URI path that follows the portion that identifies the servlet processing the request or null if there's no extra path info.


public abstract String getRequestServletPath()

Returns the portion of the request URI path that identifies the servlet processing the request.


public abstract java.net.URL getResource(String path)


throws java.net.MalformedURLException

Returns a URL for reading the resource at the specified path or null if it doesn't exist.


public abstract java.io.InputStream getResourceAsStream(String path)

Returns an InputStream for reading the resource at the specified path or null if it doesn't exist.


public abstract java.util.Set getResourcePaths(String path)

Returns a Set of all resource paths that starts with the specified path.


public abstract Object getResponse()

Returns the native object representing the environment-specific response data. In servlet environment, this is a javax.servlet.http.HttpServletResponse instance.


public abstract Object getSession(boolean create)

Returns the native object representing the environment-specific session data, creating one if it doesn't exist and create is true. In servlet environment, this is a javax.servlet.http.HttpSession instance.


public abstract java.util.Map getSessionMap()

Returns a mutable Map representing the session scope, keyed by variable name with Object values.


public abstract java.security.Principal getUserPrincipal()

Returns the Principal for the authenticated user or null if the current user isn't authenticated by the container.


public abstract boolean isUserInRole(String role)

Returns the true if the authenticated user is associated with the specified role.


public abstract void log(String message)

Writes the specified message to the application log.


public abstract void log(String message, Throwable exception)

Writes the specified message and exception to the application log.


public abstract void redirect(String path) throws java.io.IOException

Sends a redirect response to redirect the client to the resource at the specified path.

FacesContext

An instance of a subclass of this abstract class provides access to JSF-specific context information and methods. Note that an instance of this class and the objects it provides access to are associated with the thread processing a request, and references to any of these instances must not be passed to another thread.

Synopsis

Class name:

javax.faces.context.FacesContext

Extends:

None

Implements:

None

Constructors


public FacesContext()

Creates an instance.

Methods


public abstract void addMessage(String clientId, javax.faces.application.FacesMessage message)

Adds the specified message to the message queue, for the specified component or as a global message if the client ID is null.


public abstract javax.faces.application.Application getApplication()

Returns the Application this request belongs to.


public abstract java.util.Iterator getClientIdsWithMessages()

Returns an Iterator over all client IDs for which at least one message is queued.


public static javax.faces.context.FacesContext getCurrentInstance()

Returns the FacesContext instance for the current request.


public abstract javax.faces.context.ExternalContext getExternalContext()

Returns the ExternalContext instance for the current request.


public abstract javax.faces.application.FacesMessage.Severity getMaximumSeverity()

Returns the maximum severity of all queued messages.


public abstract java.util.Iterator getMessages()

Returns an Iterator over all queued FacesMessage instances.


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

Returns an Iterator over all queued FacesMessage instances for the specified client ID or over all global messages if clientId is null.


public abstract javax.faces.render.RenderKit getRenderKit()

Returns the RenderKit for the current view, or null if there's no render kit ID defined for the view or it doesn't match a registered RenderKit.


public abstract boolean getRenderResponse()

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


public abstract boolean getResponseComplete()

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


public abstract javax.faces.context.ResponseStream getResponseStream()

Returns the ResponseStream the context has been configured with for rendering a binary response or null if not set.


public abstract javax.faces.context.ResponseWriter getResponseWriter()

Returns the ResponseWriter the context has been configured with for rendering a textual response or null if not set.


public abstract javax.faces.component.UIViewRoot getViewRoot()

Returns the root component for the view's component tree or null if not set.


public abstract void release()

Releases all resources associated with this context.


public abstract void renderResponse()

Marks that the request processing must continue in the Render Response phase as soon as the current phase is completed.


public abstract void responseComplete()

Marks that a response has already been sent and that the request processing must be terminated as soon as the current phase is completed.


protected static void setCurrentInstance(javax.faces.context.FacesContext context)

Sets the FacesContext for the current thread or to null if the thread is no longer processing a JSF request.


public abstract void setResponseStream(javax.faces.context.ResponseStream rs)

Sets the ResponseStream for rendering a binary response.


public abstract void setResponseWriter(javax.faces.context.ResponseWriter rw)

Sets the ResponseWriter for rendering a textual response.


public abstract void setViewRoot(javax.faces.component.UIViewRoot viewRoot)

Sets the root component for the view's component tree.

FacesContextFactory

An instance of a subclass of this abstract class is a factory for the FacesContext instance for a request. An implementation may use a pool of context instances and recycle them for new requests.

Synopsis

Class name:

javax.faces.context.FacesContextFactory

Extends:

None

Implements:

None

Constructors


public FacesContextFactory()

Creates an instance.

Methods


public abstract javax.faces.application.Application getFacesContext(Object context, Object request, Object response, javax.faces.lifecycle.Lifecycle lifecycle)

Returns a FacesContext instance for handling a request, initialized with all the provided references.

ResponseStream

An instance of a subclass of this abstract class provides a stream for rendering a binary response.

Synopsis

Class name:

javax.faces.context.ResponseStream

Extends:

java.io.OutputStream

Implements:

None

Constructors


public ResponseStream()

Creates an instance.

ResponseWriter

An instance of a subclass of this abstract class provides methods for rendering a textual response, with special methods for writing markup elements.

Synopsis

Class name:

javax.faces.context.ResponseWriter

Extends:

java.io.Writer

Implements:

None

Constructors


public ResponseWriter()

Creates an instance.

Methods


public abstract javax.faces.context.ResponseWriter cloneWithWriter(java.io.Writer writer)

Returns a new instance wrapped around the provided Writer.


public abstract void endDocument( ) throws java.io.IOException

Closes any open tag (if any) and writes what is needed to end the document (if anything).


public abstract void endElement(String name) throws java.io.IOException

Closes any open tag (if any) and writes what is needed to close the named element.


public abstract void flush( ) throws java.io.IOException

Closes any open tag (if any) and flushes any buffered output (if any) to the underlying Writer or OutputStream, but does not flush the underlying output object.


public abstract String getCharacterEncoding()

Returns the character encoding this instance is configured to use.


public abstract String getContentType()

Returns the content MIME type this instance is configured to use.


public abstract void startDocument( ) throws java.io.IOException

Writes what is needed to start the document (if anything).


public abstract void startElement(String name, javax.faces.component.UIComponent component) throws java.io.IOException

Writes beginning of the start tag for the named element, up to and including the element name. Attributes can then be added by calls to the writeAttribute() and writeURIAttribute() methods, and the start tag closed by calls to endElement(), endDocument(), startElement( ), writeComment(), writeText( ), close(), flush( ), or write(). The component reference may be used to associate the element with the component it's rendered for.


public abstract void writeAttribute(String name, Object value, String property) throws java.io.IOException

Writes the specified attribute name with the specified value for the currently open element, after appropriate escaping of special characters for the content type being generated. The property name may be used to associate the attribute with the component property or attribute it corresponds to.


public abstract void writeComment(Object comment) throws java.io.IOException

Closes any open tag (if any) and writes the comment in a format appropriate for the content type being generated.


public abstract void writeText(Object text) throws java.io.IOException

Closes any open tag (if any) and writes the specified text, after appropriate escaping of special characters for the content type being generated. The property name may be used to associate the attribute with the component property or attribute it corresponds to.


public abstract void writeURIAttribute(String name, Object value, String property) throws java.io.IOException

Writes the specified attribute name with the specified URI value for the currently open element, after appropriate escaping of special characters for the content type being generated. The property name may be used to associate the attribute with the component property or attribute it corresponds to.

    Previous Section  < Day Day Up >  Next Section