javax.faces.context
Class ExternalContext

java.lang.Object
  extended byjavax.faces.context.ExternalContext

public abstract class ExternalContext
extends java.lang.Object

This class allows the Faces API to be unaware of the nature of its containing environment. For example, this class allows Faces to run in either a Servlet or a Portlet. This class can be seen as an extension of FacesContext.


Constructor Summary
ExternalContext()
           
 
Method Summary
abstract  void dispatchMessage(java.lang.String requestURI)
          Dispatch a request to the apropriate context.
abstract  java.lang.String encodeActionURL(java.lang.String sb)
          Force any URL that causes an action to work within a portal/portlet.
abstract  java.lang.String encodeNamespace(java.lang.String aValue)
          PENDING(edburns): this does nothing for Servlets.
abstract  java.lang.String encodeResourceURL(java.lang.String sb)
          Force any URL that references a resource to work within a portal/portlet.
abstract  java.lang.String encodeURL(java.lang.String url)
          A wrapper for ServletResponse.encodeURL().
abstract  java.util.Map getApplicationMap()
          Calling get(key) on the Map obtained from this method is equivalent to getting the ServletContext for this request and calling getAttribute(key) on it.
abstract  java.lang.Object getContext()
           
abstract  java.lang.String getInitParameter(java.lang.String name)
          A wrapper for ServletContext.getInitParameter().
abstract  java.util.Map getInitParameterMap()
          Calling get(key) on the Map obtained from this method is equivalent to getting the ServletContext for this request and calling getInitParam(key) on it.
abstract  java.lang.Object getRequest()
           
abstract  java.lang.String getRequestContextPath()
          A wrapper for HttpServletRequest.getContextPath().
abstract  java.util.Map getRequestCookieMap()
          Calling get(key) on the Map obtained from this method is equivalent to getting the ServletRequest for this request and looking through the Cookie[] returned by calling getCookies() and finding a cookie with the name of key.
abstract  Cookie[] getRequestCookies()
          A wrapper for HttpServletRequest.getCookies().
abstract  java.util.Map getRequestHeaderMap()
          Calling get(key) on the Map obtained from this method is equivalent to getting the ServletRequest for this request and calling getHeader(key) on it.
abstract  java.util.Map getRequestHeaderValuesMap()
          Calling get(key) on the Map obtained from this method is equivalent to getting the ServletRequest for this request and calling getHeaders(key) on it.
abstract  java.util.Locale getRequestLocale()
          A wrapper for ServletRequest.getLocale().
abstract  java.util.Map getRequestMap()
          Calling get(key) on the Map obtained from this method is equivalent to getting the ServletRequest for this request and calling getAttribute(key) on it.
abstract  java.util.Map getRequestParameterMap()
          Calling get(key) on the Map obtained from this method is equivalent to getting the ServletRequest for this request and calling getParameter(key) on it.
abstract  java.util.Iterator getRequestParameterNames()
          This is simply a wrapper for ServletRequest.getParameterNames().
abstract  java.util.Map getRequestParameterValuesMap()
          Similar to getRequestParameterMap, but useful for those parameters that can have multiple values with one key.
abstract  java.lang.String getRequestPathInfo()
          A wrapper for ServletRequest.getPathInfo().
abstract  java.io.InputStream getResourceAsStream(java.lang.String path)
          A wrapper for ServletContext.getResourceAsStream().
abstract  java.util.Set getResourcePaths(java.lang.String path)
          A wrapper for ServletContext.getResourcePaths().
abstract  java.lang.Object getResponse()
           
abstract  java.lang.Object getSession(boolean create)
           
abstract  java.util.Map getSessionMap()
          Calling get(key) on the Map obtained from this method is equivalent to getting the HttpSession for this request and calling getAttribute(key) on it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExternalContext

public ExternalContext()
Method Detail

getSession

public abstract java.lang.Object getSession(boolean create)
Parameters:
create - true - to create a new session for this request if necessary; false to return null if there's no current session
Returns:
the HttpSession instance for the session associated with the current request (if any); otherwise, return null.

getContext

public abstract java.lang.Object getContext()
Returns:
the ServletContext object for the web application associated with this request.

getRequest

public abstract java.lang.Object getRequest()
Returns:
the ServletRequest object representing the current request that is being processed.

getResponse

public abstract java.lang.Object getResponse()
Returns:
the ServletResponse object representing the current response that is being rendered.

getApplicationMap

public abstract java.util.Map getApplicationMap()

Calling get(key) on the Map obtained from this method is equivalent to getting the ServletContext for this request and calling getAttribute(key) on it. Similar rules apply for other Map methods where they make sense.

Returns:
a Map that wraps the ServletContext's attribute set.

getSessionMap

public abstract java.util.Map getSessionMap()

Calling get(key) on the Map obtained from this method is equivalent to getting the HttpSession for this request and calling getAttribute(key) on it. Similar rules apply for * other Map methods where they make sense.

Returns:
a Map that wraps the HttpSession's attribute set.

getRequestMap

public abstract java.util.Map getRequestMap()

Calling get(key) on the Map obtained from this method is equivalent to getting the ServletRequest for this request and calling getAttribute(key) on it. Similar rules apply for * other Map methods where they make sense.

Returns:
a Map that wraps the Request's attribute set.

getRequestParameterMap

public abstract java.util.Map getRequestParameterMap()

Calling get(key) on the Map obtained from this method is equivalent to getting the ServletRequest for this request and calling getParameter(key) on it. Similar rules apply for other Map methods where they make sense.

Returns:
a Map of all the parameters sent with this request.

getRequestParameterValuesMap

public abstract java.util.Map getRequestParameterValuesMap()

Similar to getRequestParameterMap, but useful for those parameters that can have multiple values with one key.

Calling get(key) on the Map obtained from this method is equivalent to getting the ServletRequest for this request and calling getParameterValues(key) on it. Similar rules apply for other Map methods where they make sense.

Returns:
a Map that wraps the getParameterValues() result set.

getRequestParameterNames

public abstract java.util.Iterator getRequestParameterNames()
This is simply a wrapper for ServletRequest.getParameterNames(). We took the liberty of returning an Iterator instead of an Enumeration.

Returns:
an Iterator of the names of the parameters for this request.

getRequestHeaderMap

public abstract java.util.Map getRequestHeaderMap()

Calling get(key) on the Map obtained from this method is equivalent to getting the ServletRequest for this request and calling getHeader(key) on it. Similar rules apply for other Map methods where they make sense.

Returns:
a Map that wraps the Header set for this request.

getRequestHeaderValuesMap

public abstract java.util.Map getRequestHeaderValuesMap()

Calling get(key) on the Map obtained from this method is equivalent to getting the ServletRequest for this request and calling getHeaders(key) on it. Similar rules apply for other Map methods where they make sense.

Returns:
a Map that wraps the Header set for this request, but calls getHeaders() instead of getHeader().

getRequestCookieMap

public abstract java.util.Map getRequestCookieMap()

Calling get(key) on the Map obtained from this method is equivalent to getting the ServletRequest for this request and looking through the Cookie[] returned by calling getCookies() and finding a cookie with the name of key. Similar rules apply for other Map methods where they make sense.

Returns:
a Map that wraps the Cookie set for this request.

getRequestLocale

public abstract java.util.Locale getRequestLocale()

A wrapper for ServletRequest.getLocale().


getRequestPathInfo

public abstract java.lang.String getRequestPathInfo()

A wrapper for ServletRequest.getPathInfo().


getRequestContextPath

public abstract java.lang.String getRequestContextPath()

A wrapper for HttpServletRequest.getContextPath().


getRequestCookies

public abstract Cookie[] getRequestCookies()

A wrapper for HttpServletRequest.getCookies().


getInitParameter

public abstract java.lang.String getInitParameter(java.lang.String name)

A wrapper for ServletContext.getInitParameter().


getInitParameterMap

public abstract java.util.Map getInitParameterMap()

Calling get(key) on the Map obtained from this method is equivalent to getting the ServletContext for this request and calling getInitParam(key) on it. Similar rules apply for other Map methods where they make sense.

Returns:
a Map that wraps the ServletContext's init parameter set.

getResourcePaths

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

A wrapper for ServletContext.getResourcePaths().


getResourceAsStream

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

A wrapper for ServletContext.getResourceAsStream().


encodeActionURL

public abstract java.lang.String encodeActionURL(java.lang.String sb)

Force any URL that causes an action to work within a portal/portlet. This causes the URL to have the required redirection for the specific portal to be included

Parameters:
sb - The input URL to be reformatted

encodeResourceURL

public abstract java.lang.String encodeResourceURL(java.lang.String sb)

Force any URL that references a resource to work within a portal/portlet. This causes the URL to have the required redirection for the specific portal to be included. In reality, it simply returns an absolute URL.

Parameters:
sb - The input URL to be reformatted

encodeNamespace

public abstract java.lang.String encodeNamespace(java.lang.String aValue)
PENDING(edburns): this does nothing for Servlets. What does it to for Portlets?


encodeURL

public abstract java.lang.String encodeURL(java.lang.String url)

A wrapper for ServletResponse.encodeURL().


dispatchMessage

public abstract void dispatchMessage(java.lang.String requestURI)
                              throws java.io.IOException,
                                     FacesException

Dispatch a request to the apropriate context. In the case of servlets, this is done via "forward", but for portlets, it must use "include".

Parameters:
requestURI - The input URI of the request tree.
Throws:
java.io.IOException
FacesException