org.apache.myfaces.trinidad.context
Class RequestContext

java.lang.Object
  extended by org.apache.myfaces.trinidad.context.RequestContext

public abstract class RequestContext
extends Object

Context class for all per-request and per-webapp information required by Trinidad. A RequestContext object can be retrieved with the static getCurrentInstance() method. There is one and only one RequestContext object active in any one thread.

This class does not extend FacesContext; this is intentional, as extending FacesContext requires taking over the FacesContextFactory.


Nested Class Summary
static class RequestContext.Accessibility
           
static class RequestContext.ClientValidation
           
static class RequestContext.OutputMode
          Enumeration representing OutputModes
 
Field Summary
static String VARIABLE_NAME
          Name of the EL implicit variable ("requestContext") that is used to expose this context object.
 
Constructor Summary
protected RequestContext()
          Creates an RequestContext.
 
Method Summary
abstract  void addPartialTarget(javax.faces.component.UIComponent newTarget)
          Add a component as a partial target.
abstract  void addPartialTargets(javax.faces.component.UIComponent from, String... targets)
          Add components relative to the given component as partial targets.
abstract  void addPartialTriggerListeners(javax.faces.component.UIComponent listener, String[] trigger)
          Adds a listener on a set of particular triggering components.
 void attach()
          Attaches a RequestContext to the current thread.
 javax.faces.component.visit.VisitContext createVisitContext(javax.faces.context.FacesContext context, Collection<String> ids, Set<javax.faces.component.visit.VisitHint> hints, javax.faces.event.PhaseId phaseId)
          Deprecated. use VisitContext#createVisitContext(FacesContext, Collection, Set) instead
abstract  RequestContext.Accessibility getAccessibilityMode()
          Returns the name of the current accessibility mode.
abstract  AccessibilityProfile getAccessibilityProfile()
          Returns the accessibility profile for the current request.
abstract  Agent getAgent()
          Returns the Agent information for the current context
 ConcurrentMap<String,Object> getApplicationScopedConcurrentMap()
          Gets a per application concurrent map.
abstract  ChangeManager getChangeManager()
          Gets the ChangeManager for the current application.
abstract  RequestContext.ClientValidation getClientValidation()
          Returns the name of the current client validation mode.
abstract  Map<String,List<Color>> getColorPalette()
          Returns a Map that takes color palette names as keys, and returns the color palette as a result.
 ComponentContextManager getComponentContextManager()
          Get the component context manager.
abstract  String getCurrencyCode()
          Return the ISO 4217 currency code used by default for formatting currency fields when those fields do not specify an explicit currency field via their converter.
static RequestContext getCurrentInstance()
          Retrieves the RequestContext active for the current thread.
abstract  char getDecimalSeparator()
          Return the separator used as the decimal point.
abstract  DialogService getDialogService()
          Returns an DialogService, which exposes a number of APIs needed by component and framework developers.
abstract  Map<Object,Map<Object,String>> getFormatter()
          Returns a Map that performs message formatting with a recursive Map structure.
abstract  Locale getFormattingLocale()
          Returns the formatting locale.
abstract  Map<String,Object> getHelpSystem()
          Returns a Map that will accept help system properties as keys, and return an URL as a result.
abstract  Map<String,Object> getHelpTopic()
          Returns a Map that will accept topic names as keys, and return an URL as a result.
abstract  char getNumberGroupingSeparator()
          Return the separator used for groups of numbers.
abstract  String getOracleHelpServletUrl()
          Return the URL to an Oracle Help for the Web servlet.
abstract  String getOutputMode()
          Returns the "output mode" - printable, etc.
 RequestContext.OutputMode getOutputModeEnum()
          Returns the OutputMode enumeration
abstract  Map<String,Object> getPageFlowScope()
          Returns a Map of objects at "pageFlow" scope.
abstract  PageFlowScopeProvider getPageFlowScopeProvider()
          Gets the PageFlowScopeProvider for the current application.
abstract  PageResolver getPageResolver()
          Gets the PageResolver for the current application.
abstract  Set<javax.faces.component.UIComponent> getPartialTargets(javax.faces.component.UIComponent newTarget)
          Returns the set of partial targets related to a given UIComponent.
 Map<String,Object> getProcessScope()
          Deprecated. use getPageFlowScope()
abstract  RegionManager getRegionManager()
          Gets the RegionManager for the current application.
abstract  String getSkinFamily()
          Returns the name of the preferred skin family.
 String getSkinVersion()
          Returns the name of the skin version that goes with the skin-family.
abstract  TimeZone getTimeZone()
          Returns the default TimeZone used for interpreting and formatting date values.
abstract  int getTwoDigitYearStart()
          Returns the year offset for parsing years with only two digits.
abstract  Long getUploadedFileMaxDiskSpace()
           
abstract  Long getUploadedFileMaxMemory()
           
abstract  UploadedFileProcessor getUploadedFileProcessor()
           
abstract  String getUploadedFileTempDir()
           
abstract  Map<String,Object> getViewMap()
          Method to obtain a Map stored on the view.
abstract  Map<String,Object> getViewMap(boolean create)
          Method to obtain a Map stored on the view.
 WindowManager getWindowManager()
           Returns the WindowManager for this request.
 Map<String,Object> getWindowMap()
          Returns a Map of objects associated with the current window if any.
abstract  boolean isAnimationEnabled()
          Returns the system wide setting to turn animation on/off.
abstract  boolean isClientValidationDisabled()
          Returns true if client-side validation should be disabled.
abstract  boolean isDebugOutput()
          Returns true if output should contain debugging information.
abstract  boolean isInternalViewRequest(javax.faces.context.FacesContext context)
          Determines whether the current View Root is an internal view
abstract  boolean isPartialRequest(javax.faces.context.FacesContext context)
          Method to indicate if this current HTTP request is a partial page rendering request.
abstract  boolean isPostback()
          Returns true if JSF is currently processing a postback request.
abstract  boolean isRightToLeft()
          Returns true if the user should be shown output in right-to-left.
abstract  void launchDialog(javax.faces.component.UIViewRoot dialogRoot, Map<String,Object> dialogParameters, javax.faces.component.UIComponent source, boolean useWindow, Map<String,Object> windowProperties)
          Launch a dialog, optionally raising it in a new dialog window.
abstract  void partialUpdateNotify(javax.faces.component.UIComponent updated)
          Called when any component gets updated.
 void release()
          Releases the RequestContext object.
abstract  javax.faces.component.UIComponent restoreComponent(Object state)
          Restores the state of a component.
abstract  void returnFromDialog(Object returnValue, Map<Object,Object> returnParameters)
          Returns from a dialog raised by a UIXCommand component, or any component implementing DialogSource, or any direct calls to launchDialog().
abstract  Object saveComponent(javax.faces.component.UIComponent component)
          Saves the state of a UIComponent tree into an Object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VARIABLE_NAME

public static final String VARIABLE_NAME
Name of the EL implicit variable ("requestContext") that is used to expose this context object.

See Also:
Constant Field Values
Constructor Detail

RequestContext

protected RequestContext()
Creates an RequestContext. RequestContext is abstract and may not be instantiated directly.

See Also:
RequestContextFactory
Method Detail

getCurrentInstance

public static RequestContext getCurrentInstance()
Retrieves the RequestContext active for the current thread.


getPageFlowScope

public abstract Map<String,Object> getPageFlowScope()
Returns a Map of objects at "pageFlow" scope.


getProcessScope

@Deprecated
public final Map<String,Object> getProcessScope()
Deprecated. use getPageFlowScope()


getViewMap

public abstract Map<String,Object> getViewMap()
Method to obtain a Map stored on the view.

This calls getViewMap(boolean) with a true value for create.

This is a pre-cursor implementation to the JSF 2.0 UIViewRoot.getViewMap() function. The implementation is taken from the initial UIViewRoot implementation in JSF but without the event notification support.


getViewMap

public abstract Map<String,Object> getViewMap(boolean create)
Method to obtain a Map stored on the view.

This is a pre-cursor implementation to the JSF 2.0 UIViewRoot.getViewMap() function. The implementation is taken from the initial UIViewRoot implementation in JSF but without the event notification support.

Parameters:
create - if the map should be created if it already does not exist.

getWindowMap

public Map<String,Object> getWindowMap()
Returns a Map of objects associated with the current window if any. If there is no current window, the Session Map is returned.

Returns:
Map for storing objects associated with the current window.
See Also:
Window.getWindowMap()

returnFromDialog

public abstract void returnFromDialog(Object returnValue,
                                      Map<Object,Object> returnParameters)
Returns from a dialog raised by a UIXCommand component, or any component implementing DialogSource, or any direct calls to launchDialog().

Parameters:
returnValue - the value to be delivered in the the ReturnEvent
See Also:
ReturnEvent

getDialogService

public abstract DialogService getDialogService()
Returns an DialogService, which exposes a number of APIs needed by component and framework developers. This will only rarely be needed by page authors.


launchDialog

public abstract void launchDialog(javax.faces.component.UIViewRoot dialogRoot,
                                  Map<String,Object> dialogParameters,
                                  javax.faces.component.UIComponent source,
                                  boolean useWindow,
                                  Map<String,Object> windowProperties)
Launch a dialog, optionally raising it in a new dialog window.

The dialog will receive a new pageFlowScope map, which includes all the values of the currently available pageFlowScope as well as a set of properties passed to this function in the dialogParameters map. Changes to this newly created scope will not be visible once the dialog returns.

Parameters:
dialogRoot - the UIViewRoot for the page being launched
dialogParameters - a set of parameters to populate the newly created pageFlowScope
source - the UIComponent that launched the dialog and should receive the ReturnEvent when the dialog is complete.
useWindow - if true, use a popup window for the dialog if available on the current user agent device
windowProperties - the set of UI parameters used to modify the window, if one is used. The set of properties that\ are supported will depend on the RenderKit, but common examples include "width", "height", "top" and "left".

isPostback

public abstract boolean isPostback()
Returns true if JSF is currently processing a postback request. isPostback() will return false if this is a request for an initial render of a page (that is, if Apply Request Values never executes), or if during the request the user is navigated to a different page (because of a navigation rule, etc). For example, during a request that results in a navigation to a new page, isPostback() will return true from Apply Request Values to Invoke Application, then false afterwards; whereas if there was no navigation, it would return true

The value of this method is undefined during (or before) the Restore View phase, but can be used in the afterPhase() method of a PhaseListener for Restore View.


isPartialRequest

public abstract boolean isPartialRequest(javax.faces.context.FacesContext context)
Method to indicate if this current HTTP request is a partial page rendering request.

Parameters:
context - the FacesContext object for the request we are processing
Returns:
is this request a PPR request?

isDebugOutput

public abstract boolean isDebugOutput()
Returns true if output should contain debugging information.


isClientValidationDisabled

public abstract boolean isClientValidationDisabled()
Returns true if client-side validation should be disabled.


getOutputMode

public abstract String getOutputMode()
Returns the "output mode" - printable, etc.


getOutputModeEnum

public RequestContext.OutputMode getOutputModeEnum()
Returns the OutputMode enumeration

Returns:
OutputMode

getSkinFamily

public abstract String getSkinFamily()
Returns the name of the preferred skin family.


getSkinVersion

public String getSkinVersion()
Returns the name of the skin version that goes with the skin-family.


isInternalViewRequest

public abstract boolean isInternalViewRequest(javax.faces.context.FacesContext context)
Determines whether the current View Root is an internal view

Parameters:
context - Faces context
Returns:
true if the current View Root is an internal view, false otherwise

getAccessibilityMode

public abstract RequestContext.Accessibility getAccessibilityMode()
Returns the name of the current accessibility mode.


getAccessibilityProfile

public abstract AccessibilityProfile getAccessibilityProfile()
Returns the accessibility profile for the current request.


getClientValidation

public abstract RequestContext.ClientValidation getClientValidation()
Returns the name of the current client validation mode.


isAnimationEnabled

public abstract boolean isAnimationEnabled()
Returns the system wide setting to turn animation on/off.


isRightToLeft

public abstract boolean isRightToLeft()
Returns true if the user should be shown output in right-to-left.


getFormattingLocale

public abstract Locale getFormattingLocale()
Returns the formatting locale. Converters without an explicit locale should use this to format values. If not set, converters should default to the value of FacesContext.getViewRoot().getLocale(). This will, by default, simply return null.


getNumberGroupingSeparator

public abstract char getNumberGroupingSeparator()
Return the separator used for groups of numbers. If NUL (zero), use the default separator for the current language.


getDecimalSeparator

public abstract char getDecimalSeparator()
Return the separator used as the decimal point. If NUL (zero), use the default separator for the current language.


getCurrencyCode

public abstract String getCurrencyCode()
Return the ISO 4217 currency code used by default for formatting currency fields when those fields do not specify an explicit currency field via their converter. If this returns null, the default code for the current locale will be used.


getTwoDigitYearStart

public abstract int getTwoDigitYearStart()
Returns the year offset for parsing years with only two digits. If not set this is defaulted to 1950 This is used by @link{org.apache.myfaces.trinidad.faces.view.converter.DateTimeConverter} while converting strings to Date object.


getOracleHelpServletUrl

public abstract String getOracleHelpServletUrl()
Return the URL to an Oracle Help for the Web servlet.


getHelpTopic

public abstract Map<String,Object> getHelpTopic()
Returns a Map that will accept topic names as keys, and return an URL as a result.


getHelpSystem

public abstract Map<String,Object> getHelpSystem()
Returns a Map that will accept help system properties as keys, and return an URL as a result.


getTimeZone

public abstract TimeZone getTimeZone()
Returns the default TimeZone used for interpreting and formatting date values.


getChangeManager

public abstract ChangeManager getChangeManager()
Gets the ChangeManager for the current application.


getApplicationScopedConcurrentMap

public ConcurrentMap<String,Object> getApplicationScopedConcurrentMap()
Gets a per application concurrent map. There is no synchronization with ServletContext attributes.


getPageFlowScopeProvider

public abstract PageFlowScopeProvider getPageFlowScopeProvider()
Gets the PageFlowScopeProvider for the current application.


getPageResolver

public abstract PageResolver getPageResolver()
Gets the PageResolver for the current application.


getRegionManager

public abstract RegionManager getRegionManager()
Gets the RegionManager for the current application.


addPartialTarget

public abstract void addPartialTarget(javax.faces.component.UIComponent newTarget)
Add a component as a partial target. In response to a partial event, only components registered as partial targets are re-rendered. For a component to be successfully re-rendered when it is manually added with this API, it should have an explictly set "id". If not, partial re-rendering may or may not work depending on the component.


addPartialTargets

public abstract void addPartialTargets(javax.faces.component.UIComponent from,
                                       String... targets)
Add components relative to the given component as partial targets.

See addPartialTarget(UIComponent) for more information.

Parameters:
from - the component to use as a relative reference for any relative IDs in the list of targets
targets - array of targets relative to the from component that should be added as targets.
See Also:
ComponentUtils#findRelativeComponent(UIComponent, String)

getPartialTargets

public abstract Set<javax.faces.component.UIComponent> getPartialTargets(javax.faces.component.UIComponent newTarget)
Returns the set of partial targets related to a given UIComponent.


addPartialTriggerListeners

public abstract void addPartialTriggerListeners(javax.faces.component.UIComponent listener,
                                                String[] trigger)
Adds a listener on a set of particular triggering components. If one of the named components gets updated in response to a partial event, then this listener component will be rerendered during the render phase (i.e. it will be added as a partialTarget). The list should consist of names suitable for use with the findComponent method on UIComponent.


partialUpdateNotify

public abstract void partialUpdateNotify(javax.faces.component.UIComponent updated)
Called when any component gets updated. Any partial target components listening on this component will be added to the partialTargets list in the render phase.


createVisitContext

public final javax.faces.component.visit.VisitContext createVisitContext(javax.faces.context.FacesContext context,
                                                                         Collection<String> ids,
                                                                         Set<javax.faces.component.visit.VisitHint> hints,
                                                                         javax.faces.event.PhaseId phaseId)
Deprecated. use VisitContext#createVisitContext(FacesContext, Collection, Set) instead

Creates a VisitContext instance for use with UIComponent.visitTree(javax.faces.component.visit.VisitContext, javax.faces.component.visit.VisitCallback).

Parameters:
context - the FacesContext for the current request
ids - the client ids of the components to visit. If null, all components will be visited.
hints - the VisitHints to apply to the visit
phaseId. - ignored.
Returns:
a VisitContext instance that is initialized with the specified ids and hints.

getUploadedFileProcessor

public abstract UploadedFileProcessor getUploadedFileProcessor()

getUploadedFileMaxMemory

public abstract Long getUploadedFileMaxMemory()

getUploadedFileMaxDiskSpace

public abstract Long getUploadedFileMaxDiskSpace()

getUploadedFileTempDir

public abstract String getUploadedFileTempDir()

getColorPalette

public abstract Map<String,List<Color>> getColorPalette()
Returns a Map that takes color palette names as keys, and returns the color palette as a result.


getFormatter

public abstract Map<Object,Map<Object,String>> getFormatter()
Returns a Map that performs message formatting with a recursive Map structure. The first key must be the message formatting mask, and the second the first parameter into the message. (The formatter Map supports only a single parameter at this time.)


getAgent

public abstract Agent getAgent()
Returns the Agent information for the current context


saveComponent

public abstract Object saveComponent(javax.faces.component.UIComponent component)
Saves the state of a UIComponent tree into an Object. The Object will be serializable, unless a UIComponent in this tree contains a non-serializable property. This method does not check that condition.

Parameters:
component - the component
Returns:
an Object that can be passed to restoreComponent() to reinstantiate the state

restoreComponent

public abstract javax.faces.component.UIComponent restoreComponent(Object state)
                                                            throws ClassNotFoundException,
                                                                   InstantiationException,
                                                                   IllegalAccessException
Restores the state of a component.

Parameters:
state - an Object created by a prior call to saveComponent().
Returns:
the component
Throws:
ClassNotFoundException
InstantiationException
IllegalAccessException

getWindowManager

public WindowManager getWindowManager()

Returns the WindowManager for this request. A non-null WindowManager will always be returned.

The default implementation uses the first WindowManagerFactory specified implementation class in a file named org.apache.myfaces.trinidad.context.WindowManagerFactory in the META-INF/services directory and uses the WindowManagerFactory to create the WindowManager for this Session. If no WindowManagerFactory is found, a default WindowManager that never returns any Windows is used.

Returns:
the WindowManager used for this Session.

getComponentContextManager

public ComponentContextManager getComponentContextManager()
Get the component context manager.

Returns:
The manager of component context changes to be used to suspend and resume component specific context changes.

release

public void release()
Releases the RequestContext object. This method must only be called by the code that created the RequestContext.

Throws:
IllegalStateException - if no RequestContext is attached to the thread, or the attached context is not this object

attach

public void attach()
Attaches a RequestContext to the current thread. This method should only be called by a RequestContext object itself.

Throws:
IllegalStateException - if an RequestContext is already attached to the thread


Copyright © 2001-2012 The Apache Software Foundation. All Rights Reserved.