net.sf.jasperreports.jsf.context
Class ExternalContextHelper

java.lang.Object
  extended by net.sf.jasperreports.jsf.context.ExternalContextHelper

public abstract class ExternalContextHelper
extends Object

Helper class that will provide with utility methods related with the treatment of the faces' ExternalContext.

Author:
A. Alonso Dominguez

Field Summary
protected static int BUFFER_SIZE
           
 
Constructor Summary
protected ExternalContextHelper()
          Protected constructor to prevent instantiation.
 
Method Summary
abstract  Collection<ContentType> getAcceptedContentTypes(javax.faces.context.ExternalContext context)
           
static String getPortletVersion()
          Obtains the current portlet version in use.
abstract  String getRequestServerName(javax.faces.context.ExternalContext context)
          Obtains the server name of the current request.
abstract  String getRequestURI(javax.faces.context.ExternalContext context)
          Gets the request uri.
abstract  String getResourceRealPath(javax.faces.context.ExternalContext context, String name)
          Obtains the real path name of the resource local to the current context.
 Map<String,String> getViewCacheMap(javax.faces.context.ExternalContext context)
          Obtains the view chache map used to restore views which contains report references.
 String getViewId(javax.faces.context.ExternalContext context)
          Obtains the view identifier associated with the current request.
static boolean isFacesBridgeAvailable()
          Detects if the faces bridge is available for this application.
static boolean isPortletAvailable()
          Detects if the portlet environment is available for this application.
static boolean isServletContext(javax.faces.context.ExternalContext context)
          Detects if working with a servlet context.
protected static ExternalContextHelper newInstance(javax.faces.context.ExternalContext context)
          Obtains the application local instance of the ExternalContextHelper.
abstract  ReportRenderRequest restoreReportRequest(javax.faces.context.ExternalContext context)
          Creates a ReportRenderRequest based on the data code in the current ExternalContext.
abstract  void writeHeaders(javax.faces.context.ExternalContext context, ReportRenderer renderer, UIReport report)
          Writes the report headers into the current response using the report renderer.
abstract  void writeResponse(javax.faces.context.ExternalContext context, ContentType contentType, InputStream stream)
          Writes the report contents into the context response.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BUFFER_SIZE

protected static final int BUFFER_SIZE
See Also:
Constant Field Values
Constructor Detail

ExternalContextHelper

protected ExternalContextHelper()
Protected constructor to prevent instantiation.

Method Detail

newInstance

protected static ExternalContextHelper newInstance(javax.faces.context.ExternalContext context)
                                            throws InvalidEnvironmentException
Obtains the application local instance of the ExternalContextHelper.

Parameters:
context - the current ExternalContext
Returns:
an instance of the ExternalContextHelper
Throws:
InvalidEnvironmentException

isFacesBridgeAvailable

public static boolean isFacesBridgeAvailable()
Detects if the faces bridge is available for this application.

Returns:
true if the faces bridge is available - false otherwise

isPortletAvailable

public static boolean isPortletAvailable()
Detects if the portlet environment is available for this application.

Returns:
true if the Portlet environment is available - false otherwise

getPortletVersion

public static String getPortletVersion()
Obtains the current portlet version in use.

Returns:
the current portlet version

isServletContext

public static boolean isServletContext(javax.faces.context.ExternalContext context)
Detects if working with a servlet context.

Parameters:
context - the current ExternalContext
Returns:
true if the Portlet context is available - false otherwise

getAcceptedContentTypes

public abstract Collection<ContentType> getAcceptedContentTypes(javax.faces.context.ExternalContext context)

restoreReportRequest

public abstract ReportRenderRequest restoreReportRequest(javax.faces.context.ExternalContext context)
Creates a ReportRenderRequest based on the data code in the current ExternalContext.

Parameters:
context - the current ExternalContext
Returns:
A representation of the request render request

getRequestURI

public abstract String getRequestURI(javax.faces.context.ExternalContext context)
Gets the request uri.

Parameters:
context - the context
Returns:
the request uri

getRequestServerName

public abstract String getRequestServerName(javax.faces.context.ExternalContext context)
Obtains the server name of the current request.

Parameters:
context - the current ExternalContext
Returns:
the server name

getResourceRealPath

public abstract String getResourceRealPath(javax.faces.context.ExternalContext context,
                                           String name)
Obtains the real path name of the resource local to the current context.

Parameters:
context - the current ExternalContext
name - the resource name
Returns:
the resource real path name

getViewCacheMap

public final Map<String,String> getViewCacheMap(javax.faces.context.ExternalContext context)
Obtains the view chache map used to restore views which contains report references.

Parameters:
context - the current ExternalContext
Returns:
the view cache map

getViewId

public final String getViewId(javax.faces.context.ExternalContext context)
Obtains the view identifier associated with the current request.

Parameters:
context - the current ExternalContext
Returns:
the view identifier

writeHeaders

public abstract void writeHeaders(javax.faces.context.ExternalContext context,
                                  ReportRenderer renderer,
                                  UIReport report)
                           throws IOException
Writes the report headers into the current response using the report renderer.

Parameters:
context - the current ExternalContext
renderer - the report renderer instance
report - the report component instance
Throws:
IOException - if any input or output error happens when writing the report headers

writeResponse

public abstract void writeResponse(javax.faces.context.ExternalContext context,
                                   ContentType contentType,
                                   InputStream stream)
                            throws IOException
Writes the report contents into the context response.

Parameters:
context - the context
contentType - the content type
stream - source from which read the data
Throws:
IOException - Signals that an I/O exception has occurred.


Copyright © 2011 SourceForge.net. All Rights Reserved.