public abstract class BridgeContext extends Object
BridgeContext contains the runtime specific state the bridge makes public so its various independent
pieces can work together to properly operate. Simplistically, the bridge is a controller and a set of Faces
extensions that work together execute Faces requests in a portlet container. By encapsulating state that is shared
between these pieces, an extensible, pluggable bridge is supported as bridge implementors can now extend a base
implementation by extending or overriding any of the Faces extensions (and other hook points) required to add their
specific behaviors.
A new BridgeContext is created in each bridge request doFacesRequest(). After the bridge
controller has initialized the context the SystemEvent BridgeContextInitializedEvent is dispatched to
any registered listeners for further transformation. Once the bridge has acquired the FacesContext, the
BridgeContext is added to the FacesContext scope making it freely available from anywhere
within Faces during that request.
| Constructor and Description |
|---|
BridgeContext() |
| Modifier and Type | Method and Description |
|---|---|
abstract String |
appendClientWindowId(String url)
Provide the ability to append the Client Window Id to urls that need to be encoded.
|
abstract Map<String,Object> |
getAttributes()
This
Map is a place to put extra (implementation specific) bridge state or anything else whose
lifetime matches this scope. |
abstract BridgeConfig |
getBridgeConfig() |
abstract BridgeRequestScopeManager |
getBridgeRequestScopeManager() |
abstract BridgeRequestScope |
getBridgeScope()
Returns the Bridge request scope corresponding to current view and mode.
|
abstract BridgeRequestScope |
getBridgeScope(String viewId,
String mode)
Returns the Bridge request scope corresponding to passed viewId and mode.
|
static BridgeContext |
getCurrentInstance()
Return the
BridgeContext instance for the request that is being processed by the current thread. |
abstract String |
getDefaultFacesViewIdForRequest(boolean excludeQueryString)
Returns the default Faces (viewid) target configured for the current request's
PortletMode. |
abstract String |
getFacesViewId(boolean excludeQueryString)
Returns the Faces (viewid) currently targeted.
|
abstract String |
getFacesViewIdFromPath(String path)
Returns the Faces (viewid) target as represented in the path.
|
abstract String |
getFacesViewIdFromRequest(boolean excludeQueryString)
Returns the Faces (viewid) target as described by the request.
|
abstract String |
getNavigationalQueryString()
The bridge allows viewIds in the faces-config.xml to contain queryStrings.
|
abstract javax.portlet.PortletContext |
getPortletContext() |
abstract javax.portlet.PortletRequest |
getPortletRequest() |
abstract Bridge.PortletPhase |
getPortletRequestPhase()
Gets the request phase govering this context.
|
abstract javax.portlet.PortletResponse |
getPortletResponse() |
abstract List<String> |
getPreFacesRequestAttrNames() |
abstract Map<String,String[]> |
getPreservedActionParams() |
abstract String |
getRedirectViewId() |
abstract String |
getRenderRedirectQueryString()
The bridge is required to support redirects to other Faces views during render.
|
abstract String |
getSavedViewStateParam()
Faces stores the current view state in a hidden field in the response.
|
abstract String |
getViewHistory(String mode)
Returns the last viewId rendered for a given mode.
|
abstract boolean |
hasRenderRedirect() |
abstract boolean |
hasRenderRedirectAfterDispatch() |
abstract boolean |
isBridgeRequestScopePreserved() |
static void |
log(String s)
Convenience methods for classes that need to log without having or knowing whether they are currently executing
in a BridgeContext
|
static void |
log(String s,
Throwable t)
Convenience methods for classes that need to log without having or knowing whether they are currently executing
in a BridgeContext
|
abstract void |
release()
Called at the end of bridge request processing.
|
abstract void |
setBridgeConfig(BridgeConfig config)
Sets the
BridgeConfig that corresponds to this instance. |
abstract void |
setBridgeRequestScopePreserved(boolean preserve)
Indicates whether the controller should preserve the bridge request scope.
|
protected static void |
setCurrentInstance(BridgeContext context)
Set the
FacesContext instance for the request that is being processed by the current thread. |
abstract void |
setNavigationQueryString(String queryString)
The bridge allows viewIds in the faces-config.xml to contain queryStrings.
|
abstract void |
setPortletContext(javax.portlet.PortletContext context)
Sets the
PortletContext of the portlet invoking this bridge. |
abstract void |
setPortletRequest(javax.portlet.PortletRequest request)
Sets the
PortletRequest that invoked the bridge. |
abstract void |
setPortletRequestPhase(Bridge.PortletPhase phase)
Sets the request phase govering this context.
|
abstract void |
setPortletResponse(javax.portlet.PortletResponse response)
Sets the
PortletResponse that invoked the bridge. |
abstract void |
setPreFacesRequestAttrNames(List<String> names)
Sets the names of the attributes which existed before the
FacesContext is acquired. |
abstract void |
setPreservedActionParams(Map<String,String[]> actionParamMap)
Map of the action parameters that have been preserved for this render request. |
abstract void |
setRedirectViewId(String viewId) |
abstract void |
setRenderRedirect(boolean redirect)
Sets whether a render redirect has occurred in this request.
|
abstract void |
setRenderRedirectAfterDispatch(boolean afterDispatch)
Set if the renderRedirect occurred after the (JSP) dispatch.
|
abstract void |
setRenderRedirectQueryString(String queryString)
The bridge is required to support redirects to other Faces views during render.
|
abstract void |
setSavedViewStateParam(String savedViewStateParam)
Faces stores the current view state in a hidden field in the response.
|
abstract void |
setViewHistory(String mode,
String viewId,
boolean preserveRenderParams)
Bridge maintains in the session the last viewId accessed in each mode.
|
public abstract void release()
public abstract void setPortletContext(javax.portlet.PortletContext context)
PortletContext of the portlet invoking this bridge.context - public abstract javax.portlet.PortletContext getPortletContext()
PortletContext of the portlet invoking this bridge.public abstract void setPortletRequest(javax.portlet.PortletRequest request)
PortletRequest that invoked the bridge.request - public abstract javax.portlet.PortletRequest getPortletRequest()
PortletRequest that invoked the bridge.public abstract void setPortletResponse(javax.portlet.PortletResponse response)
PortletResponse that invoked the bridge.response - public abstract javax.portlet.PortletResponse getPortletResponse()
PortletResponse that invoked the bridge.public abstract void setPortletRequestPhase(Bridge.PortletPhase phase)
Note: as per specification, its more typical for the Faces developer to rely on the request attribute containing this same information. Its included in the BridgeContext primarily for bridge (extension) implementors.
phase - public abstract Bridge.PortletPhase getPortletRequestPhase()
Note: as per specification, its more typical for the Faces developer to rely on the request attribute containing this same information. Its included in the BridgeContext primarily for bridge (extension) implementors.
public abstract void setBridgeConfig(BridgeConfig config)
BridgeConfig that corresponds to this instance.config - public abstract BridgeConfig getBridgeConfig()
BridgeConfig that corresponds to this instance.public abstract Map<String,Object> getAttributes()
Map is a place to put extra (implementation specific) bridge state or anything else whose
lifetime matches this scope.Map of bridge context scoped attributespublic abstract void setBridgeRequestScopePreserved(boolean preserve)
true means the request scope should be preserved. false means the request scope
should not be preserved. The default is truepreserve - public abstract boolean isBridgeRequestScopePreserved()
boolean indicating whether the controller should preserve the bridge request scope or
not. true means the request scope should be preserved. false means the request
scope should not be preserved. The default is truepublic abstract void setSavedViewStateParam(String savedViewStateParam)
StateManager) to extract the parameter value and the controller to manage the state. The value is
conveyed between these two subsystems through here. This method sets the captured view state parameter value for
later retrieval.savedViewStateParam - public abstract String getSavedViewStateParam()
StateManager) to extract the parameter value and the controller to manage the state. The value is
conveyed between these two subsystems through here.public abstract void setNavigationQueryString(String queryString)
NavigationHandler
resolves such navigation and create the asscoiated view and Faces itself doesn't expect these query strings, the
bridge needs to extract this query string and stash its value for later retrieval/use by the controller which
encodes these extra parameters as part of its action response.queryString - query string portion of a viewIdpublic abstract String getNavigationalQueryString()
NavigationHandler
resolves such navigation and create the associated view and Faces itself doesn't expect these query strings, the
bridge needs to extract this query string and stash its value for later retrieval/use by the controller which
encodes these extra parameters as part of its action response.UIViewRootpublic abstract void setRenderRedirectQueryString(String queryString)
Such redirects are detected in ExternalContext.redirect() but implemented by the controller. This
sets the query string portion of the redirect url (exclusive of the ?) so its available to the controller in
handling the render redirect. This method automatically calls setRenderRedirect(true); to flag that
a renderRedirect has been detected.
queryString - public abstract String getRenderRedirectQueryString()
Such redirects are detected in ExternalContext.redirect() but implemented by the controller.
public abstract void setRedirectViewId(String viewId)
viewId - public abstract String getRedirectViewId()
public abstract void setRenderRedirect(boolean redirect)
setRenderRedirectQueryString.redirect - public abstract boolean hasRenderRedirect()
true if there has been one in this
request. Default is false.public abstract void setRenderRedirectAfterDispatch(boolean afterDispatch)
dispatch.forward() can't
be called twice in the same request. Setting this will allow the bridge to know to use
dispatch.include() for rendering the "redirected" view.afterDispatch - public abstract boolean hasRenderRedirectAfterDispatch()
true
indicates the redirect ocurred after the dispatch. false by default.public abstract void setPreFacesRequestAttrNames(List<String> names)
FacesContext is acquired. Used for
attribute exclusion, request resetting before a render redirect, as well as allowing the FacesContext to release
request attrs during its release.names - list of attribute names that exist in the request scope before acquiring the FacesContextpublic abstract List<String> getPreFacesRequestAttrNames()
FacesContext was acquired.public abstract void setPreservedActionParams(Map<String,String[]> actionParamMap)
Map of the action parameters that have been preserved for this render request. Set by the controller
when processing a render so the ExternalContext.encodeActionURL() can exclude them from its encoding
of a self-referencing portlet: url. I.e. one that is supposed to redisplay preserving the existing state.actionParamMap - Map of the action parameters in this render request.public abstract Map<String,String[]> getPreservedActionParams()
Map of the action parameters in this render request.public abstract void setViewHistory(String mode, String viewId, boolean preserveRenderParams)
mode - name of the portlet modeviewId - JSF view that we are currently in/adding to the history. Includes a QS of the various state needed to
restore this viewpreserveRenderParams - indicates whether the render params are carried into the history. Generally true is the
view's mode hasn't changed from what the bridge finds encoded in its render params and
false otherwise.public abstract String getViewHistory(String mode)
mode - public abstract String getFacesViewIdFromRequest(boolean excludeQueryString) throws BridgeInvalidViewPathException
ExternalContext if available. If not, then the target is computed from the BridgeContext's
PortletRequestexcludeQueryString - if true then only the target Faces viewId is returned regardless of whether the viewId
contains a query string. I.e. unlike core Faces, the bridge allows the default viewIds and viewIds in
the Faces navigation rules to contain query strings that augment the view. For example one can include
a new mode in a Faces navigation rule. This boolean controls whether this extra query string portion
of a viewid is returned or not.null if the request
doesn't explicitly specify a target or if the target specified in the request doesn't match the request's
PortletMode. When a target viewId is returned it may contain contain (an optional) query
string if not specifically excluded.BridgeInvalidViewPathExceptionpublic abstract String getFacesViewId(boolean excludeQueryString) throws BridgeInvalidViewPathException
FacesContext has a current UIViewRoot, it returns its id. Otherwise it computes the
target viewId as follows: returns the result of calling getFacesViewIdFromRequest() if
not null otherwise return the result of getDefaultViewIdForRequest().excludeQueryString - if true then only the target Faces viewId is returned regardless of whether the viewId
contains a query string. I.e. unlike core Faces, the bridge allows the default viewIds and viewIds in
the Faces navigation rules to contain query strings that augment the view. For example one can include
a new mode in a Faces navigation rule. This boolean controls whether this extra query string portion
of a viewid is returned or not.BridgeInvalidViewPathExceptionpublic abstract BridgeRequestScope getBridgeScope()
getFacesViewId and PortletRequest.getPortletMode().toString().public abstract BridgeRequestScope getBridgeScope(String viewId, String mode)
viewId - scope's viewIdmode - scope's portlet modepublic abstract BridgeRequestScopeManager getBridgeRequestScopeManager()
public abstract String getFacesViewIdFromPath(String path) throws BridgeInvalidViewPathException
path - contains encoded viewId to be extracted. path can either contain the context path or be
relative to it. If path contains a query string it is ignored.BridgeInvalidViewPathExceptionpublic abstract String getDefaultFacesViewIdForRequest(boolean excludeQueryString) throws BridgeDefaultViewNotSpecifiedException
PortletMode. The
value must use the request contained in the ExternalContext if available. If not, then the target is
computed from the BridgeContext's
PortletRequestexcludeQueryString - if true then only the target Faces viewId is returned regardless of whether the viewId
contains a query string. I.e. unlike core Faces, the bridge allows the default viewIds and viewIds in
the Faces navigation rules to contain query strings that augment the view. For example one can include
a new mode in a Faces navigation rule. This boolean controls whether this extra query string portion
of a viewid is returned or not.PortletMode.
The return value may contain contain (an optional) query string if not specifically excluded.BridgeDefaultViewNotSpecifiedExceptionpublic abstract String appendClientWindowId(String url)
url - URL that requires the Client Window Id appended to it.public static BridgeContext getCurrentInstance()
BridgeContext instance for the request that is being processed by the current thread.protected static void setCurrentInstance(BridgeContext context)
Set the FacesContext instance for the request that is being processed by the current thread.
context - The FacesContext instance for the current thread, or null if this thread no
longer has a FacesContext instance.public static void log(String s, Throwable t)
s - t - public static void log(String s)
s - Copyright © 2015 JBoss by Red Hat. All rights reserved.