com.liferay.faces.bridge.context
Class BridgeContext

java.lang.Object
  extended by com.liferay.faces.bridge.context.BridgeContext
Direct Known Subclasses:
BridgeContextCompatImpl, BridgeContextWrapper

public abstract class BridgeContext
extends Object

This is an abstract class modeled after the JSF FacesContext in that it encapsulates a ThreadLocal singleton instance. The instance contains contextual information related to the bridge.

Author:
Neil Griffin

Constructor Summary
BridgeContext()
           
 
Method Summary
abstract  void dispatch(String path)
          Creates a PortletRequestDispatcher for the specified path and issues a forward/include as appropriate.
abstract  BridgeActionURL encodeActionURL(String url)
          Encodes a bridge "action" URL, meaning a URL that conforms to the deviation requirements of ExternalContext.encodeActionURL(String) listed in Section 6.1.3.1 of the Bridge Spec.
abstract  BridgePartialActionURL encodePartialActionURL(String url)
          Encodes a bridge "partial action" URL, meaning a URL that is intended to be used for Ajax (partial request) processing.
abstract  BridgeRedirectURL encodeRedirectURL(String baseUrl, Map<String,List<String>> parameters)
          Encodes a bridge "redirect" URL, meaning a URL that conforms to the deviation requirements of ExternalContext.redirect(String) listed in Section 6.1.3.1 of the Bridge Spec.
abstract  BridgeResourceURL encodeResourceURL(String url)
          Encodes a bridge "resource" URL, meaning a URL that conforms to the deviation requirements of ExternalContext.encodeResourceURL(String) listed in Section 6.1.3.1 of the Bridge Spec.
abstract  Map<String,Object> getAttributes()
          Returns the attribute map associated with this context.
abstract  BridgeConfig getBridgeConfig()
          Convenience method that returns the BridgeConfig for this context.
abstract  BridgeRequestScope getBridgeRequestScope()
          Convenience method that returns the BridgeRequestScope for this context.
static BridgeContext getCurrentInstance()
           
abstract  String getDefaultRenderKitId()
          Returns the default Render Kit ID, which is optionally specified by developers with the in the WEB-INF/portlet.xml descriptor.
abstract  Map<String,String> getDefaultViewIdMap()
          Returns an immutable Map whose keys are determined by PortletMode.toString() and whose values are retrieved from the following sections of the WEB-INF/portlet.xml descriptor.
abstract  String getFacesViewId()
          Returns the target view (and optional query string) as described in section 5.2.3 of the Bridge Spec titled "Determining the Target View".
abstract  String getFacesViewIdFromPath(String viewPath)
          Returns the viewId associated with the specified viewPath by examining the servlet-mapping entries from the WEB-INF/web.xml descriptor.
abstract  String getFacesViewIdFromPath(String viewPath, boolean mustExist)
          Returns the viewId associated with the specified viewPath by examining the servlet-mapping entries from the WEB-INF/web.xml descriptor.
abstract  String getFacesViewQueryString()
          Returns the query-string part of the to-view-id of the last navigation-rule that fired, or the query-string part of the Bridge.VIEW_ID request attribute.
abstract  IncongruityContext getIncongruityContext()
           
abstract  String getInitParameter(String name)
          NOTE: PROPOSE-FOR-BRIDGE3-API Returns the value of the specified initialization parameter.
abstract  javax.portlet.PortletConfig getPortletConfig()
          Return the current PortletConfig.
abstract  PortletContainer getPortletContainer()
          Returns the PortletContainer associated with the current request.
abstract  javax.portlet.PortletContext getPortletContext()
          Returns the PortletContext associated with the current portlet.
abstract  javax.portlet.PortletRequest getPortletRequest()
          Returns the PortletRequest associated with the current request.
abstract  Bridge.PortletPhase getPortletRequestPhase()
          Returns the Bridge.PortletPhase associated with the current portlet lifecycle phase.
abstract  javax.portlet.PortletResponse getPortletResponse()
          Returns the PortletResponse associated with the current response.
abstract  List<String> getPreFacesRequestAttrNames()
          Returns a list of attribute names that existed prior to the FacesContext being created.
abstract  Map<String,String[]> getPreservedActionParams()
          Returns the Map of preserved action parameters.
abstract  BridgeRedirectURL getRenderRedirectURL()
          Gets the render-redirect URL that was set during a render-redirect.
abstract  Map<String,String> getRequestHeaderMap()
           
abstract  Map<String,String[]> getRequestHeaderValuesMap()
           
abstract  Map<String,String> getRequestParameterMap()
           
abstract  Map<String,String[]> getRequestParameterValuesMap()
           
abstract  String getRequestPathInfo()
          Returns the pathInfo associated with the current viewId.
abstract  String getRequestServletPath()
          Returns the servletPath associated with the current viewId.
abstract  String getResponseNamespace()
           
abstract  Writer getResponseOutputWriter()
          Returns a Writer that is meant to be used as a return value for ExternalContext.getResponseOutputWriter().
abstract  String getSavedViewState()
          Returns the saved view state.
abstract  boolean isBridgeRequestScopePreserved()
          Returns the flag indicating whether or not the current BridgeRequestScope is preserved at the end of the RenderRequest.
abstract  boolean isPreserveActionParams()
          Determines whether or not the "javax.portlet.faces.preserveActionParams" init-param has been configured in the WEB-INF/portlet.xml descriptor.
abstract  boolean isProcessingAfterViewContent()
          Flag indicating whether or not the bridge is processing Bridge.AFTER_VIEW_CONTENT.
abstract  boolean isRenderRedirect()
          Returns the flag indicating whether or not a render redirect occurred.
abstract  boolean isRenderRedirectAfterDispatch()
          Returns a flag indicating whether or not a render-redirect has occurred after dispatching to a JSP.
abstract  void redirect(String url)
          If the specified url is external to this portlet context, then calling this method causes a redirection to the specified url.
abstract  void release()
          Performs any necessary cleanup.
static void setCurrentInstance(BridgeContext bridgeContext)
           
abstract  void setPortletRequest(javax.portlet.PortletRequest portletRequest)
          Preserves the PortletRequest associated with the current request.
abstract  void setPortletResponse(javax.portlet.PortletResponse portletResponse)
          Preserves the PortletResponse associated with the current response.
abstract  void setProcessingAfterViewContent(boolean processingAfterViewContent)
          Sets the flag indicating whether or not the bridge is processing Bridge.AFTER_VIEW_CONTENT.
abstract  void setRenderRedirectAfterDispatch(boolean renderRedirectAfterDispatch)
          Sets a flag indicating whether or not a render-redirect has occurred after dispatching to a JSP.
abstract  void setRenderRedirectURL(BridgeRedirectURL renderRedirectURL)
          Sets the render-redirect URL that is associated with a render-redirect.
abstract  void setSavedViewState(String savedViewState)
          Preserves the saved view state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BridgeContext

public BridgeContext()
Method Detail

getCurrentInstance

public static BridgeContext getCurrentInstance()

setCurrentInstance

public static void setCurrentInstance(BridgeContext bridgeContext)

dispatch

public abstract void dispatch(String path)
                       throws IOException
Creates a PortletRequestDispatcher for the specified path and issues a forward/include as appropriate.

Throws:
IOException

encodeActionURL

public abstract BridgeActionURL encodeActionURL(String url)
Encodes a bridge "action" URL, meaning a URL that conforms to the deviation requirements of ExternalContext.encodeActionURL(String) listed in Section 6.1.3.1 of the Bridge Spec.

Parameters:
url - The URL to be encoded.
Returns:
A new instance of BrideActionURL that conforms to the proper encoding.

encodePartialActionURL

public abstract BridgePartialActionURL encodePartialActionURL(String url)
Encodes a bridge "partial action" URL, meaning a URL that is intended to be used for Ajax (partial request) processing. Note that ExternalContext.encodePartialActionURL(String) was added in JSF 2.0 which means there are no Bridge Spec deviation requirements yet.

Parameters:
url - The URL to be encoded.
Returns:
A new instance of BridgePartialActionURL that conforms to the proper encoding.

encodeRedirectURL

public abstract BridgeRedirectURL encodeRedirectURL(String baseUrl,
                                                    Map<String,List<String>> parameters)
Encodes a bridge "redirect" URL, meaning a URL that conforms to the deviation requirements of ExternalContext.redirect(String) listed in Section 6.1.3.1 of the Bridge Spec.

Parameters:
baseUrl - The URL to be encoded.
parameters - The URL parameters that are to be included as part of the encoding.
Returns:
A new instance of BridgeRedirectURL that conforms to the proper encoding.

encodeResourceURL

public abstract BridgeResourceURL encodeResourceURL(String url)
Encodes a bridge "resource" URL, meaning a URL that conforms to the deviation requirements of ExternalContext.encodeResourceURL(String) listed in Section 6.1.3.1 of the Bridge Spec.

Parameters:
url - The URL to be encoded.
Returns:
A new instance of BridgeResourceURL that conforms to the proper encoding.

redirect

public abstract void redirect(String url)
                       throws IOException
If the specified url is external to this portlet context, then calling this method causes a redirection to the specified url. Otherwise, this method will effectively "navigate" to the Faces viewId found in the URL path.

Throws:
IOException

release

public abstract void release()
Performs any necessary cleanup.


getAttributes

public abstract Map<String,Object> getAttributes()
Returns the attribute map associated with this context.


getBridgeConfig

public abstract BridgeConfig getBridgeConfig()
Convenience method that returns the BridgeConfig for this context.


getBridgeRequestScope

public abstract BridgeRequestScope getBridgeRequestScope()
Convenience method that returns the BridgeRequestScope for this context.


isBridgeRequestScopePreserved

public abstract boolean isBridgeRequestScopePreserved()
Returns the flag indicating whether or not the current BridgeRequestScope is preserved at the end of the RenderRequest.

Returns:
true if the scope is to be preserved, otherwise false. Default value is false which is an optimization for JSF 2 that deviates from the Bridge Spec. See FACES-219.

getDefaultRenderKitId

public abstract String getDefaultRenderKitId()
Returns the default Render Kit ID, which is optionally specified by developers with the in the WEB-INF/portlet.xml descriptor. If not specified by the developer, then returns null.


getDefaultViewIdMap

public abstract Map<String,String> getDefaultViewIdMap()

Returns an immutable Map whose keys are determined by PortletMode.toString() and whose values are retrieved from the following sections of the WEB-INF/portlet.xml descriptor.

          <init-param>
          <name>javax.portlet.faces.defaultViewId.view</name>
          <value>/xhtml/portletViewMode.xhtml</value>
          </init-param>
          <init-param>
          <name>javax.portlet.faces.defaultViewId.edit</name>
          <value>/xhtml/portletEditMode.xhtml</value>
          </init-param>
          <init-param>
          <name>javax.portlet.faces.defaultViewId.help</name>
          <value>/xhtml/portletHelpMode.xhtml</value>
          </init-param>
 

Returns:

getFacesViewId

public abstract String getFacesViewId()
                               throws BridgeDefaultViewNotSpecifiedException,
                                      BridgeInvalidViewPathException
Returns the target view (and optional query string) as described in section 5.2.3 of the Bridge Spec titled "Determining the Target View".

Throws:
{@link - BridgeDefaultViewNotSpecifiedException} when the default view is not specified in the WEB-INF/portlet.xml descriptor.
{@link - BridgeInvalidViewPathException} when the Bridge.VIEW_PATH request attribute contains an invalid path such that the target view cannot be determined.
BridgeDefaultViewNotSpecifiedException
BridgeInvalidViewPathException

getFacesViewIdFromPath

public abstract String getFacesViewIdFromPath(String viewPath)
Returns the viewId associated with the specified viewPath by examining the servlet-mapping entries from the WEB-INF/web.xml descriptor.

Parameters:
viewPath - The path to the view.
Returns:
The viewId associated with the specified viewPath (providing that the view physically exists). Otherwise returns null.

getFacesViewIdFromPath

public abstract String getFacesViewIdFromPath(String viewPath,
                                              boolean mustExist)
Returns the viewId associated with the specified viewPath by examining the servlet-mapping entries from the WEB-INF/web.xml descriptor.

Parameters:
viewPath - The path to the view.
mustExist - Flag indicating whether or not the view must physically exist in order for the viewId to be returned.
Returns:
The viewId associated with the specified viewPath. Otherwise returns null.

getFacesViewQueryString

public abstract String getFacesViewQueryString()
Returns the query-string part of the to-view-id of the last navigation-rule that fired, or the query-string part of the Bridge.VIEW_ID request attribute.


isRenderRedirectAfterDispatch

public abstract boolean isRenderRedirectAfterDispatch()
Returns a flag indicating whether or not a render-redirect has occurred after dispatching to a JSP.

Returns:
true if a render-redirect has occurred after dispatching to a JSP, otherwise false.

getIncongruityContext

public abstract IncongruityContext getIncongruityContext()

getInitParameter

public abstract String getInitParameter(String name)
NOTE: PROPOSE-FOR-BRIDGE3-API Returns the value of the specified initialization parameter. If found, return the value of the PortletConfig.getInitParameter(String) method. Otherwise, return the value of the PortletContext.getInitParameter(String) method. This provides a way for init-param values found in the WEB-INF/portlet.xml descriptor to override context-param values found in the WEB-INF/web.xml descriptor.


getPortletConfig

public abstract javax.portlet.PortletConfig getPortletConfig()
Return the current PortletConfig.


getPortletContainer

public abstract PortletContainer getPortletContainer()
Returns the PortletContainer associated with the current request.


getPortletContext

public abstract javax.portlet.PortletContext getPortletContext()
Returns the PortletContext associated with the current portlet.


getPortletRequest

public abstract javax.portlet.PortletRequest getPortletRequest()
Returns the PortletRequest associated with the current request.


setPortletRequest

public abstract void setPortletRequest(javax.portlet.PortletRequest portletRequest)
Preserves the PortletRequest associated with the current request.


getPortletRequestPhase

public abstract Bridge.PortletPhase getPortletRequestPhase()
Returns the Bridge.PortletPhase associated with the current portlet lifecycle phase.


getPortletResponse

public abstract javax.portlet.PortletResponse getPortletResponse()
Returns the PortletResponse associated with the current response.


setPortletResponse

public abstract void setPortletResponse(javax.portlet.PortletResponse portletResponse)
Preserves the PortletResponse associated with the current response.


getPreFacesRequestAttrNames

public abstract List<String> getPreFacesRequestAttrNames()
Returns a list of attribute names that existed prior to the FacesContext being created.


getPreservedActionParams

public abstract Map<String,String[]> getPreservedActionParams()
Returns the Map of preserved action parameters.


setProcessingAfterViewContent

public abstract void setProcessingAfterViewContent(boolean processingAfterViewContent)
Sets the flag indicating whether or not the bridge is processing Bridge.AFTER_VIEW_CONTENT.

Parameters:
processingAfterViewContent - true if processing, otherwise false.

setRenderRedirectAfterDispatch

public abstract void setRenderRedirectAfterDispatch(boolean renderRedirectAfterDispatch)
Sets a flag indicating whether or not a render-redirect has occurred after dispatching to a JSP.


getRenderRedirectURL

public abstract BridgeRedirectURL getRenderRedirectURL()
Gets the render-redirect URL that was set during a render-redirect.


setRenderRedirectURL

public abstract void setRenderRedirectURL(BridgeRedirectURL renderRedirectURL)
Sets the render-redirect URL that is associated with a render-redirect.


getRequestHeaderMap

public abstract Map<String,String> getRequestHeaderMap()

getRequestHeaderValuesMap

public abstract Map<String,String[]> getRequestHeaderValuesMap()

getRequestParameterMap

public abstract Map<String,String> getRequestParameterMap()

getRequestParameterValuesMap

public abstract Map<String,String[]> getRequestParameterValuesMap()

getRequestPathInfo

public abstract String getRequestPathInfo()
Returns the pathInfo associated with the current viewId.


getRequestServletPath

public abstract String getRequestServletPath()
Returns the servletPath associated with the current viewId.


getResponseNamespace

public abstract String getResponseNamespace()

getResponseOutputWriter

public abstract Writer getResponseOutputWriter()
                                        throws IOException
Returns a Writer that is meant to be used as a return value for ExternalContext.getResponseOutputWriter().

Throws:
IOException

isPreserveActionParams

public abstract boolean isPreserveActionParams()
Determines whether or not the "javax.portlet.faces.preserveActionParams" init-param has been configured in the WEB-INF/portlet.xml descriptor.

Returns:
true if the "javax.portlet.faces.preserveActionParams" init-param has a value of true, otherwise false.

getSavedViewState

public abstract String getSavedViewState()
Returns the saved view state.


setSavedViewState

public abstract void setSavedViewState(String savedViewState)
Preserves the saved view state.

Parameters:
savedViewState - The saved view state.

isProcessingAfterViewContent

public abstract boolean isProcessingAfterViewContent()
Flag indicating whether or not the bridge is processing Bridge.AFTER_VIEW_CONTENT.

Returns:
true if processing, otherwise false

isRenderRedirect

public abstract boolean isRenderRedirect()
Returns the flag indicating whether or not a render redirect occurred.



Copyright © 2014 Liferay, Inc.. All Rights Reserved.