org.edorasframework.extfaces.context
Class ExtFacesContext

java.lang.Object
  extended by javax.faces.context.FacesContext
      extended by org.edorasframework.extfaces.context.ExtFacesContext
Direct Known Subclasses:
ExtFacesContextImpl

public abstract class ExtFacesContext
extends javax.faces.context.FacesContext

The ExtFacesContext is a wrapper around the FacesContext provided by the JSF implementation, and provides a variety of convenience methods.

Author:
"Neil Griffin", mimacom ag

Field Summary
protected static ExtFacesContext instance
           
static String JAVAX_FACES_UPLOADED_FILES_MAP
           
 
Constructor Summary
ExtFacesContext()
           
 
Method Summary
abstract  void addComponentErrorMessage(String clientId, String messageId)
          Adds the specified key as a message to the FacesContext with severity javax.faces.application.FacesMessage.SEVERITY_ERROR.
abstract  void addComponentErrorMessage(String clientId, String messageId, Object... arguments)
          Adds the specified key as a global message to the FacesContext with severity javax.faces.application.FacesMessage.SEVERITY_ERROR and substitutes the specified argument(s) for the tokens in the specified key.
abstract  void addComponentErrorMessage(String clientId, String messageId, Object argument)
          Adds the specified key as a global message to the FacesContext with severity javax.faces.application.FacesMessage.SEVERITY_ERROR and substitutes the specified argument for the tokens in the specified key.
abstract  void addComponentInfoMessage(String clientId, String messageId)
          Adds the specified key as a message to the FacesContext with severity javax.faces.application.FacesMessage.SEVERITY_INFO.
abstract  void addComponentInfoMessage(String clientId, String messageId, Object... arguments)
          Adds the specified key as a global message to the FacesContext with severity javax.faces.application.FacesMessage.SEVERITY_INFO and substitutes the specified argument(s) for the tokens in the specified key.
abstract  void addComponentInfoMessage(String clientId, String messageId, Object argument)
          Adds the specified key as a global message to the FacesContext with severity javax.faces.application.FacesMessage.SEVERITY_INFO and substitutes the specified argument for the tokens in the specified key.
abstract  void addGlobalErrorMessage(String messageId)
          Adds the specified key as a global message to the FacesContext with severity javax.faces.application.FacesMessage.SEVERITY_ERROR.
abstract  void addGlobalErrorMessage(String messageId, Object... arguments)
          Adds the specified key as a global message to the FacesContext with severity javax.faces.application.FacesMessage.SEVERITY_ERROR and substitutes the specified argument(s) for the tokens in the specified key.
abstract  void addGlobalErrorMessage(String messageId, Object argument)
          Adds the specified key as a global message to the FacesContext with severity javax.faces.application.FacesMessage.SEVERITY_ERROR and substitutes the specified argument for the tokens in the specified key.
abstract  void addGlobalInfoMessage(String messageId)
          Adds the specified key as a global message to the FacesContext with severity javax.faces.application.FacesMessage.SEVERITY_INFO.
abstract  void addGlobalInfoMessage(String messageId, Object... arguments)
          Adds the specified key as a global message to the FacesContext with severity javax.faces.application.FacesMessage.SEVERITY_INFO and substitutes the specified argument(s) for the tokens in the specified key.
abstract  void addGlobalInfoMessage(String messageId, Object argument)
          Adds the specified key as a global message to the FacesContext with severity javax.faces.application.FacesMessage.SEVERITY_INFO and substitutes the specified argument for the tokens in the specified key.
abstract  void addMessage(String clientId, javax.faces.application.FacesMessage.Severity severity, String messageId)
          Adds the specified key as a message associated with the UIComponent that has the specified clientId.
abstract  void addMessage(String clientId, javax.faces.application.FacesMessage.Severity severity, String messageId, Object... arguments)
          Adds the specified key as a message associated with the UIComponent that has the specified clientId.
abstract  void addMessage(String clientId, javax.faces.application.FacesMessage.Severity severity, String messageId, Object argument)
          Adds the specified key as a message associated with the UIComponent that has the specified clientId.
abstract  javax.faces.context.FacesContext getFacesContext()
          Gets the underlying/wrapped FacesContext ThreadLocal singleton instance.
static ExtFacesContext getInstance()
          Returns the implementation singleton instance.
abstract  Locale getLocale()
          Returns the locale of the viewRoot of the current JSF FacesContext
abstract  String getMessage(Locale locale, String messageId)
          Returns the message associated with the specified messageId by delegating to the FacesMessageFactory, according to the specified locale.
abstract  String getMessage(Locale locale, String messageId, Object... arguments)
          Returns the message associated with the specified messageId by delegating to the FacesMessageFactory, according to the specified locale and arguments that are to be substituted.
abstract  String getMessage(String messageId)
          Returns the message associated with the specified messageId by delegating to the FacesMessageFactory, according to the current locale.
abstract  String getMessage(String messageId, Object... arguments)
          Returns the message associated with the specified messageId by delegating to the FacesMessageFactory, according to the current locale and arguments that are to be substituted.
abstract  javax.faces.component.UIForm getParentForm(javax.faces.component.UIComponent uiComponent)
          Return the parent form of the given component.
abstract  Object getRequestAttribute(String name)
          Returns the value of the request attribute associated with the specified name.
abstract  String getRequestContextPath()
           
abstract  String getRequestParameter(String name)
          Retrieves the specified parameter passed as part of the request
abstract  boolean getRequestParameterAsBool(String name, boolean defaultValue)
          Retrieves the specified parameter passed as part of the request as a boolean.
abstract  int getRequestParameterAsInt(String name, int defaultValue)
          Retrieves the specified parameter passed as part of the request as an integer.
abstract  long getRequestParameterAsLong(String name, long defaultValue)
          Retrieves the specified parameter passed as part of the request as an integer.
abstract  String getRequestParameterFromMap(String name)
          Retrieves the specified parameter from the ExternalContext's request parameter map.
abstract  String getRequestQueryString()
          Retrieves the value of the original "javax.servlet.forward.query_string" request attribute.
abstract  String getRequestQueryStringParameter(String name)
          Retrieves the value of the specified parameter name from the original "javax.servlet.forward.query_string" request attribute.
abstract  Object getSession(boolean create)
          Returns the session object associated with the current FacesContext.
abstract  Object getSessionAttribute(String name)
          Returns the value of the session attribute associated with the specified name.
abstract  Map<String,File> getUploadedFilesMap()
          Returns a java.util.Map of files that were uploaded as part of the PortletRequest.
abstract  javax.faces.component.UIComponent matchComponentInHierarchy(javax.faces.component.UIComponent parent, String partialClientId)
          Traverses the component tree starting at the specified UIComponent parent and returns the first UIComponent child that contains the specified partialClientId.
abstract  javax.faces.component.UIComponent matchComponentInViewRoot(String partialClientId)
          Traverses the component tree associated with the UIViewRoot of this FacesContext and returns the first UIComponent child that contains the specified partialClientId.
abstract  void navigate(String fromAction, String outcome)
          Sets the current JSF navigation to the specified outcome.
abstract  void navigateTo(String outcome)
          Sets the current JSF navigation to the specified outcome.
abstract  void recreateComponentTree()
          Delete the whole component tree.
abstract  void registerPhaseListener(javax.faces.event.PhaseListener phaseListener)
          Register a PhaseListener programatically (instead of in the faces-config.xml).
abstract  void removeChildrenFromComponentTree(String clientId)
          clear component tree since input fields will not be refreshed.
abstract  void removeMessages(String clientId)
          Removes all FacesMessage instances from this FacesContext that are associated with the specified clientId.
abstract  void removeMessagesForImmediateComponents()
          Removes all FacesMessage instances from this FacesContext that are associated with components whose immediate attribute is true.The typical use case for this method is when seemingly bogus messages are added to the FacesContext on components whose immediate attribute is true.
abstract  void removeMessagesForImmediateComponents(javax.faces.component.UIComponent uiComponent)
          Removes all FacesMessage instances from this FacesContext that are associated with components whose immediate attribute is true.The typical use case for this method is when seemingly bogus messages are added to the FacesContext on components whose immediate attribute is true.
abstract  void removeParentFormFromComponentTree(javax.faces.component.UIComponent uiComponent)
          Delete the component subtree of a given component.
abstract  void resetView()
          Causes the current view's component tree to be discarded and re-rendered.
abstract  void resetView(boolean renderResponse)
          Causes the current view's component tree to be discarded and (optionally) re-rendered.
abstract  Object resolveExpression(String elExpression)
          Returns the object associated with the specified EL expression.
static void setInstance(ExtFacesContext extFacesContext)
          Sets the implementation singleton instance.
abstract  void setRequestAttribute(String name, Object value)
          Sets the value of the a request attribute using the specified name and value.
abstract  void setSessionAttribute(String name, Object value)
          Sets the value of the a session attribute using the specified name and value.
 
Methods inherited from class javax.faces.context.FacesContext
addMessage, getApplication, getClientIdsWithMessages, getCurrentInstance, getELContext, getExternalContext, getMaximumSeverity, getMessages, getMessages, getRenderKit, getRenderResponse, getResponseComplete, getResponseStream, getResponseWriter, getViewRoot, release, renderResponse, responseComplete, setCurrentInstance, setResponseStream, setResponseWriter, setViewRoot
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JAVAX_FACES_UPLOADED_FILES_MAP

public static final String JAVAX_FACES_UPLOADED_FILES_MAP
See Also:
Constant Field Values

instance

protected static ExtFacesContext instance
Constructor Detail

ExtFacesContext

public ExtFacesContext()
Method Detail

addGlobalErrorMessage

public abstract void addGlobalErrorMessage(String messageId)
Adds the specified key as a global message to the FacesContext with severity javax.faces.application.FacesMessage.SEVERITY_ERROR.


addGlobalErrorMessage

public abstract void addGlobalErrorMessage(String messageId,
                                           Object argument)
Adds the specified key as a global message to the FacesContext with severity javax.faces.application.FacesMessage.SEVERITY_ERROR and substitutes the specified argument for the tokens in the specified key.


addGlobalErrorMessage

public abstract void addGlobalErrorMessage(String messageId,
                                           Object... arguments)
Adds the specified key as a global message to the FacesContext with severity javax.faces.application.FacesMessage.SEVERITY_ERROR and substitutes the specified argument(s) for the tokens in the specified key.


addComponentErrorMessage

public abstract void addComponentErrorMessage(String clientId,
                                              String messageId)
Adds the specified key as a message to the FacesContext with severity javax.faces.application.FacesMessage.SEVERITY_ERROR. The message will not be global, rather it will be associated with the javax.faces.component.UIComponent that is associated with the specified clientId.


addComponentErrorMessage

public abstract void addComponentErrorMessage(String clientId,
                                              String messageId,
                                              Object argument)
Adds the specified key as a global message to the FacesContext with severity javax.faces.application.FacesMessage.SEVERITY_ERROR and substitutes the specified argument for the tokens in the specified key. The message will not be global, rather it will be associated with the javax.faces.component.UIComponent that is associated with the specified clientId.


addComponentErrorMessage

public abstract void addComponentErrorMessage(String clientId,
                                              String messageId,
                                              Object... arguments)
Adds the specified key as a global message to the FacesContext with severity javax.faces.application.FacesMessage.SEVERITY_ERROR and substitutes the specified argument(s) for the tokens in the specified key. The message will not be global, rather it will be associated with the javax.faces.component.UIComponent that is associated with the specified clientId.


addGlobalInfoMessage

public abstract void addGlobalInfoMessage(String messageId)
Adds the specified key as a global message to the FacesContext with severity javax.faces.application.FacesMessage.SEVERITY_INFO.


addGlobalInfoMessage

public abstract void addGlobalInfoMessage(String messageId,
                                          Object argument)
Adds the specified key as a global message to the FacesContext with severity javax.faces.application.FacesMessage.SEVERITY_INFO and substitutes the specified argument for the tokens in the specified key.


addGlobalInfoMessage

public abstract void addGlobalInfoMessage(String messageId,
                                          Object... arguments)
Adds the specified key as a global message to the FacesContext with severity javax.faces.application.FacesMessage.SEVERITY_INFO and substitutes the specified argument(s) for the tokens in the specified key.


addComponentInfoMessage

public abstract void addComponentInfoMessage(String clientId,
                                             String messageId)
Adds the specified key as a message to the FacesContext with severity javax.faces.application.FacesMessage.SEVERITY_INFO. The message will not be global, rather it will be associated with the javax.faces.component.UIComponent that is associated with the specified clientId.


addComponentInfoMessage

public abstract void addComponentInfoMessage(String clientId,
                                             String messageId,
                                             Object argument)
Adds the specified key as a global message to the FacesContext with severity javax.faces.application.FacesMessage.SEVERITY_INFO and substitutes the specified argument for the tokens in the specified key. The message will not be global, rather it will be associated with the javax.faces.component.UIComponent that is associated with the specified clientId.


addComponentInfoMessage

public abstract void addComponentInfoMessage(String clientId,
                                             String messageId,
                                             Object... arguments)
Adds the specified key as a global message to the FacesContext with severity javax.faces.application.FacesMessage.SEVERITY_INFO and substitutes the specified argument(s) for the tokens in the specified key. The message will not be global, rather it will be associated with the javax.faces.component.UIComponent that is associated with the specified clientId.


addMessage

public abstract void addMessage(String clientId,
                                javax.faces.application.FacesMessage.Severity severity,
                                String messageId)
Adds the specified key as a message associated with the UIComponent that has the specified clientId. Specify clientId=null for global messages.


addMessage

public abstract void addMessage(String clientId,
                                javax.faces.application.FacesMessage.Severity severity,
                                String messageId,
                                Object argument)
Adds the specified key as a message associated with the UIComponent that has the specified clientId. Specify clientId=null for global messages.


addMessage

public abstract void addMessage(String clientId,
                                javax.faces.application.FacesMessage.Severity severity,
                                String messageId,
                                Object... arguments)
Adds the specified key as a message associated with the UIComponent that has the specified clientId. Specify clientId=null for global messages.


matchComponentInHierarchy

public abstract javax.faces.component.UIComponent matchComponentInHierarchy(javax.faces.component.UIComponent parent,
                                                                            String partialClientId)
Traverses the component tree starting at the specified UIComponent parent and returns the first UIComponent child that contains the specified partialClientId.


matchComponentInViewRoot

public abstract javax.faces.component.UIComponent matchComponentInViewRoot(String partialClientId)
Traverses the component tree associated with the UIViewRoot of this FacesContext and returns the first UIComponent child that contains the specified partialClientId.


navigate

public abstract void navigate(String fromAction,
                              String outcome)
Sets the current JSF navigation to the specified outcome.

Parameters:
fromAction - The "from action" as specified in a JSF navigation rule. Can be null to if no action is specified in the rule.
outcome - The "from outcome" as specified in a JSF navigation rule

navigateTo

public abstract void navigateTo(String outcome)
Sets the current JSF navigation to the specified outcome.

Parameters:
outcome - The "from outcome" as specified in a JSF navigation rule

recreateComponentTree

public abstract void recreateComponentTree()
Delete the whole component tree. This causes the tree to be rebuilt the next time it is accessed. This addresses the problem that immediate actions cannot change the values of input components. To clear these values, use this method.


registerPhaseListener

public abstract void registerPhaseListener(javax.faces.event.PhaseListener phaseListener)
Register a PhaseListener programatically (instead of in the faces-config.xml). Such a PhaseListener can therefore be controlled by spring and use dependency injection, which is not possible otherwise.

Parameters:
phaseListener -

removeChildrenFromComponentTree

public abstract void removeChildrenFromComponentTree(String clientId)
clear component tree since input fields will not be refreshed. See ClearInputComponents for more information.

Parameters:
clientId - all children of the component with this id are cleared.

removeMessages

public abstract void removeMessages(String clientId)
Removes all FacesMessage instances from this FacesContext that are associated with the specified clientId.


removeMessagesForImmediateComponents

public abstract void removeMessagesForImmediateComponents()
Removes all FacesMessage instances from this FacesContext that are associated with components whose immediate attribute is true.The typical use case for this method is when seemingly bogus messages are added to the FacesContext on components whose immediate attribute is true. This happens because UIInput.processDecodes(javax.faces.context.FacesContext) calls validate() if the the immediate attribute is true.


removeMessagesForImmediateComponents

public abstract void removeMessagesForImmediateComponents(javax.faces.component.UIComponent uiComponent)
Removes all FacesMessage instances from this FacesContext that are associated with components whose immediate attribute is true.The typical use case for this method is when seemingly bogus messages are added to the FacesContext on components whose immediate attribute is true. This happens because UIInput.processDecodes(javax.faces.context.FacesContext) calls validate() if the the immediate attribute is true.


removeParentFormFromComponentTree

public abstract void removeParentFormFromComponentTree(javax.faces.component.UIComponent uiComponent)
Delete the component subtree of a given component. This causes the subtree to be rebuilt the next time it is accessed. This addresses the problem that immediate actions cannot change the values of input components. To clear these values, use this method.

Parameters:
uiComponent -

resolveExpression

public abstract Object resolveExpression(String elExpression)
Returns the object associated with the specified EL expression.


resetView

public abstract void resetView()
Causes the current view's component tree to be discarded and re-rendered.

See Also:
resetView(boolean)

resetView

public abstract void resetView(boolean renderResponse)
Causes the current view's component tree to be discarded and (optionally) re-rendered. This is useful whenever an action causes navigation back to the current view, but the data in the backing bean(s) has changed substantially. The view is rendered as if the user is visiting for the first time.

Parameters:
renderResponse - causes the response to be rendered immediately if true.
See Also:
ClearInputComponents

getFacesContext

public abstract javax.faces.context.FacesContext getFacesContext()
Gets the underlying/wrapped FacesContext ThreadLocal singleton instance.


getLocale

public abstract Locale getLocale()
Returns the locale of the viewRoot of the current JSF FacesContext


getMessage

public abstract String getMessage(String messageId)
Returns the message associated with the specified messageId by delegating to the FacesMessageFactory, according to the current locale.


getMessage

public abstract String getMessage(String messageId,
                                  Object... arguments)
Returns the message associated with the specified messageId by delegating to the FacesMessageFactory, according to the current locale and arguments that are to be substituted.


getMessage

public abstract String getMessage(Locale locale,
                                  String messageId)
Returns the message associated with the specified messageId by delegating to the FacesMessageFactory, according to the specified locale.


getMessage

public abstract String getMessage(Locale locale,
                                  String messageId,
                                  Object... arguments)
Returns the message associated with the specified messageId by delegating to the FacesMessageFactory, according to the specified locale and arguments that are to be substituted.


getParentForm

public abstract javax.faces.component.UIForm getParentForm(javax.faces.component.UIComponent uiComponent)
Return the parent form of the given component.

Parameters:
uiComponent -
Returns:
the parent form or null if no parent form is found.

getRequestAttribute

public abstract Object getRequestAttribute(String name)
Returns the value of the request attribute associated with the specified name.


setRequestAttribute

public abstract void setRequestAttribute(String name,
                                         Object value)
Sets the value of the a request attribute using the specified name and value.


getRequestContextPath

public abstract String getRequestContextPath()
Returns:
the request context path. FacesContext.getExternalContext() ExternalContext.getRequestContextPath()

getRequestParameter

public abstract String getRequestParameter(String name)
Retrieves the specified parameter passed as part of the request


getRequestParameterAsBool

public abstract boolean getRequestParameterAsBool(String name,
                                                  boolean defaultValue)
Retrieves the specified parameter passed as part of the request as a boolean. The values "yes", "true", "y", and "1" are accetable values for "TRUE".


getRequestParameterAsInt

public abstract int getRequestParameterAsInt(String name,
                                             int defaultValue)
Retrieves the specified parameter passed as part of the request as an integer.


getRequestParameterAsLong

public abstract long getRequestParameterAsLong(String name,
                                               long defaultValue)
Retrieves the specified parameter passed as part of the request as an integer.


getRequestParameterFromMap

public abstract String getRequestParameterFromMap(String name)
Retrieves the specified parameter from the ExternalContext's request parameter map.


getRequestQueryString

public abstract String getRequestQueryString()
Retrieves the value of the original "javax.servlet.forward.query_string" request attribute.


getRequestQueryStringParameter

public abstract String getRequestQueryStringParameter(String name)
Retrieves the value of the specified parameter name from the original "javax.servlet.forward.query_string" request attribute.


getSession

public abstract Object getSession(boolean create)
Returns the session object associated with the current FacesContext.

Parameters:
create - Flag indicating whether or not a session should be created if it doesn't yet exist.

getSessionAttribute

public abstract Object getSessionAttribute(String name)
Returns the value of the session attribute associated with the specified name.


setSessionAttribute

public abstract void setSessionAttribute(String name,
                                         Object value)
Sets the value of the a session attribute using the specified name and value.


getUploadedFilesMap

public abstract Map<String,File> getUploadedFilesMap()
Returns a java.util.Map of files that were uploaded as part of the PortletRequest.


getInstance

public static ExtFacesContext getInstance()
Returns the implementation singleton instance.


setInstance

public static void setInstance(ExtFacesContext extFacesContext)
Sets the implementation singleton instance.



Copyright 2009, http://www.edorasframework.org