org.apache.myfaces.commons.util
Class ExternalContextUtils

java.lang.Object
  extended by org.apache.myfaces.commons.util.ExternalContextUtils

public final class ExternalContextUtils
extends Object

This provides some functionality for determining some things about the native request object that is not provided by JSF. This class is useful for use in places where Portlet API's may or may not be present and can also provide access to some request-specific items which are not available on the JSF ExternalContext. If portlet API's are not present, this class simply handles the Servlet Request type.


Method Summary
static int getContentLength(javax.faces.context.ExternalContext externalContext)
          Returns the content length or -1 if the unknown.
static InputStream getRequestInputStream(javax.faces.context.ExternalContext externalContext)
          Returns the request input stream if one is available
static RequestType getRequestType(javax.faces.context.ExternalContext externalContext)
          Returns the requestType of this ExternalContext.
static RequestType getRequestType(Object context, Object request)
          This method is used when a ExternalContext object is not available, like in TomahawkFacesContextFactory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getContentLength

public static final int getContentLength(javax.faces.context.ExternalContext externalContext)
Returns the content length or -1 if the unknown.

Parameters:
externalContext - the ExternalContext
Returns:
the length or -1

getRequestInputStream

public static final InputStream getRequestInputStream(javax.faces.context.ExternalContext externalContext)
                                               throws IOException
Returns the request input stream if one is available

Parameters:
externalContext -
Returns:
Throws:
IOException

getRequestType

public static final RequestType getRequestType(javax.faces.context.ExternalContext externalContext)
Returns the requestType of this ExternalContext.

Parameters:
externalContext - the current external context
Returns:
the appropriate RequestType for this external context
See Also:
RequestType

getRequestType

public static final RequestType getRequestType(Object context,
                                               Object request)
This method is used when a ExternalContext object is not available, like in TomahawkFacesContextFactory. According to TOMAHAWK-1331, the object context could receive an instance of javax.portlet.PortletContext or javax.portlet.PortletConfig, so we check both cases.

Parameters:
context -
request -
Returns:


Copyright © 2007-2011 The Apache Software Foundation. All Rights Reserved.