com.liferay.faces.bridge.context
Class BridgeContextImpl

java.lang.Object
  extended by com.liferay.faces.bridge.context.BridgeContext
      extended by com.liferay.faces.bridge.context.BridgeContextCompatImpl
          extended by com.liferay.faces.bridge.context.BridgeContextImpl

public class BridgeContextImpl
extends BridgeContextCompatImpl

Author:
Neil Griffin

Nested Class Summary
protected  class BridgeContextImpl.StringWrapper
           
 
Field Summary
static String ATTR_RESPONSE_NAMESPACE
           
 
Constructor Summary
BridgeContextImpl(BridgeConfig bridgeConfig, BridgeRequestScope bridgeRequestScope, javax.portlet.PortletConfig portletConfig, javax.portlet.PortletContext portletContext, javax.portlet.PortletRequest portletRequest, javax.portlet.PortletResponse portletResponse, Bridge.PortletPhase portletPhase, PortletContainer portletContainer, IncongruityContext incongruityContext)
           
 
Method Summary
 void dispatch(String path)
          Creates a PortletRequestDispatcher for the specified path and issues a forward/include as appropriate.
 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.
 BridgePartialActionURL encodePartialActionURL(String url)
          Encodes a bridge "partial action" URL, meaning a URL that is intended to be used for Ajax (partial request) processing.
 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.
 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.
 Map<String,Object> getAttributes()
          Returns the attribute map associated with this context.
 BridgeConfig getBridgeConfig()
          Convenience method that returns the BridgeConfig for this context.
 BridgeRequestScope getBridgeRequestScope()
          Convenience method that returns the BridgeRequestScope for this context.
 String getDefaultRenderKitId()
          Returns the default Render Kit ID, which is optionally specified by developers with the in the WEB-INF/portlet.xml descriptor.
 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.
protected  FacesView getFacesView()
          Returns an instance of FacesView that represents the target view (and optional query string) as described in section 5.2.3 of the Bridge Spec titled "Determining the Target View".
 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".
protected  String getFacesViewIdAndQueryString()
          This method returns the target view (and optional query string) as described in section 5.2.3 of the Bridge Spec titled "Determining the Target View".
 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.
 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.
 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.
 IncongruityContext getIncongruityContext()
           
 String getInitParameter(String name)
          NOTE: PROPOSE-FOR-BRIDGE3-API Returns the value of the specified initialization parameter.
 javax.portlet.PortletConfig getPortletConfig()
          Return the current PortletConfig.
 PortletContainer getPortletContainer()
          Returns the PortletContainer associated with the current request.
 javax.portlet.PortletContext getPortletContext()
          Returns the PortletContext associated with the current portlet.
 javax.portlet.PortletRequest getPortletRequest()
          Returns the PortletRequest associated with the current request.
 Bridge.PortletPhase getPortletRequestPhase()
          Returns the Bridge.PortletPhase associated with the current portlet lifecycle phase.
 javax.portlet.PortletResponse getPortletResponse()
          Returns the PortletResponse associated with the current response.
 List<String> getPreFacesRequestAttrNames()
          Returns a list of attribute names that existed prior to the FacesContext being created.
 Map<String,String[]> getPreservedActionParams()
          Returns the Map of preserved action parameters.
 BridgeRedirectURL getRenderRedirectURL()
          Gets the render-redirect URL that was set during a render-redirect.
 Map<String,String> getRequestHeaderMap()
           
 Map<String,String[]> getRequestHeaderValuesMap()
           
 Map<String,String> getRequestParameterMap()
           
protected  RequestParameterMapFactory getRequestParameterMapFactory()
           
 Map<String,String[]> getRequestParameterValuesMap()
           
 String getRequestPathInfo()
          Returns the pathInfo associated with the current viewId.
 String getRequestServletPath()
          Returns the servletPath associated with the current viewId.
 String getResponseNamespace()
           
 Writer getResponseOutputWriter()
          Returns a Writer that is meant to be used as a return value for ExternalContext.getResponseOutputWriter().
 String getSavedViewState()
          Returns the saved view state.
 boolean isBridgeRequestScopePreserved()
          Returns the flag indicating whether or not the current BridgeRequestScope is preserved at the end of the RenderRequest.
 boolean isPreserveActionParams()
          Determines whether or not the "javax.portlet.faces.preserveActionParams" init-param has been configured in the WEB-INF/portlet.xml descriptor.
 boolean isProcessingAfterViewContent()
          Flag indicating whether or not the bridge is processing Bridge.AFTER_VIEW_CONTENT.
 boolean isRenderRedirect()
          Returns the flag indicating whether or not a render redirect occurred.
 boolean isRenderRedirectAfterDispatch()
          Returns a flag indicating whether or not a render-redirect has occurred after dispatching to a JSP.
 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.
 void release()
          Performs any necessary cleanup.
 void setBridgeRequestScopePreserved(boolean bridgeRequestScopePreserved)
           
 void setPortletRequest(javax.portlet.PortletRequest portletRequest)
          Preserves the PortletRequest associated with the current request.
 void setPortletResponse(javax.portlet.PortletResponse portletResponse)
          Preserves the PortletResponse associated with the current response.
 void setPreFacesRequestAttrNames(List<String> preFacesRequestAttrNames)
           
 void setPreservedActionParams(Map<String,String[]> preservedActionParams)
           
 void setProcessingAfterViewContent(boolean processingAfterViewContent)
          Sets the flag indicating whether or not the bridge is processing Bridge.AFTER_VIEW_CONTENT.
 void setRenderRedirectAfterDispatch(boolean renderRedirectAfterDispatch)
          Sets a flag indicating whether or not a render-redirect has occurred after dispatching to a JSP.
 void setRenderRedirectURL(BridgeRedirectURL renderRedirectURL)
          Sets the render-redirect URL that is associated with a render-redirect.
 void setSavedViewState(String savedViewState)
          Preserves the saved view state.
 
Methods inherited from class com.liferay.faces.bridge.context.BridgeContextCompatImpl
partialViewContextRenderAll
 
Methods inherited from class com.liferay.faces.bridge.context.BridgeContext
getCurrentInstance, setCurrentInstance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ATTR_RESPONSE_NAMESPACE

public static final String ATTR_RESPONSE_NAMESPACE
See Also:
Constant Field Values
Constructor Detail

BridgeContextImpl

public BridgeContextImpl(BridgeConfig bridgeConfig,
                         BridgeRequestScope bridgeRequestScope,
                         javax.portlet.PortletConfig portletConfig,
                         javax.portlet.PortletContext portletContext,
                         javax.portlet.PortletRequest portletRequest,
                         javax.portlet.PortletResponse portletResponse,
                         Bridge.PortletPhase portletPhase,
                         PortletContainer portletContainer,
                         IncongruityContext incongruityContext)
Method Detail

dispatch

public void dispatch(String path)
              throws IOException
Description copied from class: BridgeContext
Creates a PortletRequestDispatcher for the specified path and issues a forward/include as appropriate.

Specified by:
dispatch in class BridgeContext
Throws:
IOException

encodeActionURL

public BridgeActionURL encodeActionURL(String url)
Description copied from class: BridgeContext
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.

Specified by:
encodeActionURL in class BridgeContext
Parameters:
url - The URL to be encoded.
Returns:
A new instance of BrideActionURL that conforms to the proper encoding.

encodePartialActionURL

public BridgePartialActionURL encodePartialActionURL(String url)
Description copied from class: BridgeContext
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.

Specified by:
encodePartialActionURL in class BridgeContext
Parameters:
url - The URL to be encoded.
Returns:
A new instance of BridgePartialActionURL that conforms to the proper encoding.

encodeRedirectURL

public BridgeRedirectURL encodeRedirectURL(String baseUrl,
                                           Map<String,List<String>> parameters)
Description copied from class: BridgeContext
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.

Specified by:
encodeRedirectURL in class BridgeContext
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 BridgeResourceURL encodeResourceURL(String url)
Description copied from class: BridgeContext
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.

Specified by:
encodeResourceURL in class BridgeContext
Parameters:
url - The URL to be encoded.
Returns:
A new instance of BridgeResourceURL that conforms to the proper encoding.

redirect

public void redirect(String url)
              throws IOException
Description copied from class: BridgeContext
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.

Specified by:
redirect in class BridgeContext
Throws:
IOException

release

public void release()
Description copied from class: BridgeContext
Performs any necessary cleanup.

Specified by:
release in class BridgeContext

getAttributes

public Map<String,Object> getAttributes()
Description copied from class: BridgeContext
Returns the attribute map associated with this context.

Specified by:
getAttributes in class BridgeContext

getBridgeConfig

public BridgeConfig getBridgeConfig()
Description copied from class: BridgeContext
Convenience method that returns the BridgeConfig for this context.

Specified by:
getBridgeConfig in class BridgeContext

getBridgeRequestScope

public BridgeRequestScope getBridgeRequestScope()
Description copied from class: BridgeContext
Convenience method that returns the BridgeRequestScope for this context.

Specified by:
getBridgeRequestScope in class BridgeContext

setBridgeRequestScopePreserved

public void setBridgeRequestScopePreserved(boolean bridgeRequestScopePreserved)

isBridgeRequestScopePreserved

public boolean isBridgeRequestScopePreserved()
Description copied from class: BridgeContext
Returns the flag indicating whether or not the current BridgeRequestScope is preserved at the end of the RenderRequest.

Specified by:
isBridgeRequestScopePreserved in class BridgeContext
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 String getDefaultRenderKitId()
Description copied from class: BridgeContext
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.

Specified by:
getDefaultRenderKitId in class BridgeContext

getDefaultViewIdMap

public Map<String,String> getDefaultViewIdMap()
Description copied from class: BridgeContext

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>
 

Specified by:
getDefaultViewIdMap in class BridgeContext
Returns:

getFacesView

protected FacesView getFacesView()
                          throws BridgeDefaultViewNotSpecifiedException,
                                 BridgeInvalidViewPathException
Returns an instance of FacesView that represents 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

getFacesViewId

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

Specified by:
getFacesViewId in class BridgeContext
Throws:
BridgeDefaultViewNotSpecifiedException
BridgeInvalidViewPathException

getFacesViewIdAndQueryString

protected String getFacesViewIdAndQueryString()
                                       throws BridgeDefaultViewNotSpecifiedException,
                                              BridgeInvalidViewPathException

This method returns the target view (and optional query string) as described in section 5.2.3 of the Bridge Spec titled "Determining the Target View".

Try#1: Get the viewId from the Bridge.VIEW_ID (javax.portlet.faces.viewId) request attribute. As described in sections 3.4 and 4.2.5 of the bridge spec, this attribute is set by the GenericFacesPortlet when it encounters the Bridge.FACES_VIEW_ID_PARAMETER request parameter.

Try#2: Get the viewId from the Bridge.VIEW_PATH (javax.portlet.faces.viewPath) request attribute. As described in sections 3.4 and 4.2.5 of the bridge spec, this attribute is set by the GenericFacesPortlet when it encounters the Bridge.FACES_VIEW_PATH_PARAMETER request parameter. If the viewId cannot be determined, then BridgeInvalidViewPathException is thrown.

Try#3: Get the viewId from a prior render-redirect (if one has occurred).

Try#4: Get the viewId from a request parameter, the name of which is dynamic depending on the Bridge.PortletPhase.

Try#5:Get the viewId from the init-param value in the portlet.xml descriptor according the current PortletMode.

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 String getFacesViewIdFromPath(String viewPath)
Description copied from class: BridgeContext
Returns the viewId associated with the specified viewPath by examining the servlet-mapping entries from the WEB-INF/web.xml descriptor.

Specified by:
getFacesViewIdFromPath in class BridgeContext
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 String getFacesViewIdFromPath(String viewPath,
                                     boolean mustExist)
Description copied from class: BridgeContext
Returns the viewId associated with the specified viewPath by examining the servlet-mapping entries from the WEB-INF/web.xml descriptor.

Specified by:
getFacesViewIdFromPath in class BridgeContext
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 String getFacesViewQueryString()
Description copied from class: BridgeContext
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.

Specified by:
getFacesViewQueryString in class BridgeContext

isRenderRedirectAfterDispatch

public boolean isRenderRedirectAfterDispatch()
Description copied from class: BridgeContext
Returns a flag indicating whether or not a render-redirect has occurred after dispatching to a JSP.

Specified by:
isRenderRedirectAfterDispatch in class BridgeContext
Returns:
true if a render-redirect has occurred after dispatching to a JSP, otherwise false.

getIncongruityContext

public IncongruityContext getIncongruityContext()
Specified by:
getIncongruityContext in class BridgeContext

getInitParameter

public String getInitParameter(String name)
Description copied from class: BridgeContext
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.

Specified by:
getInitParameter in class BridgeContext

getPortletConfig

public javax.portlet.PortletConfig getPortletConfig()
Description copied from class: BridgeContext
Return the current PortletConfig.

Specified by:
getPortletConfig in class BridgeContext

getPortletContainer

public PortletContainer getPortletContainer()
Description copied from class: BridgeContext
Returns the PortletContainer associated with the current request.

Specified by:
getPortletContainer in class BridgeContext

getPortletContext

public javax.portlet.PortletContext getPortletContext()
Description copied from class: BridgeContext
Returns the PortletContext associated with the current portlet.

Specified by:
getPortletContext in class BridgeContext

getPortletRequest

public javax.portlet.PortletRequest getPortletRequest()
Description copied from class: BridgeContext
Returns the PortletRequest associated with the current request.

Specified by:
getPortletRequest in class BridgeContext

setPortletRequest

public void setPortletRequest(javax.portlet.PortletRequest portletRequest)
Description copied from class: BridgeContext
Preserves the PortletRequest associated with the current request.

Specified by:
setPortletRequest in class BridgeContext

getPortletRequestPhase

public Bridge.PortletPhase getPortletRequestPhase()
Description copied from class: BridgeContext
Returns the Bridge.PortletPhase associated with the current portlet lifecycle phase.

Specified by:
getPortletRequestPhase in class BridgeContext

getPortletResponse

public javax.portlet.PortletResponse getPortletResponse()
Description copied from class: BridgeContext
Returns the PortletResponse associated with the current response.

Specified by:
getPortletResponse in class BridgeContext

setPortletResponse

public void setPortletResponse(javax.portlet.PortletResponse portletResponse)
Description copied from class: BridgeContext
Preserves the PortletResponse associated with the current response.

Specified by:
setPortletResponse in class BridgeContext

getPreFacesRequestAttrNames

public List<String> getPreFacesRequestAttrNames()
Description copied from class: BridgeContext
Returns a list of attribute names that existed prior to the FacesContext being created.

Specified by:
getPreFacesRequestAttrNames in class BridgeContext

setPreFacesRequestAttrNames

public void setPreFacesRequestAttrNames(List<String> preFacesRequestAttrNames)

getPreservedActionParams

public Map<String,String[]> getPreservedActionParams()
Description copied from class: BridgeContext
Returns the Map of preserved action parameters.

Specified by:
getPreservedActionParams in class BridgeContext

setPreservedActionParams

public void setPreservedActionParams(Map<String,String[]> preservedActionParams)

setProcessingAfterViewContent

public void setProcessingAfterViewContent(boolean processingAfterViewContent)
Description copied from class: BridgeContext
Sets the flag indicating whether or not the bridge is processing Bridge.AFTER_VIEW_CONTENT.

Specified by:
setProcessingAfterViewContent in class BridgeContext
Parameters:
processingAfterViewContent - true if processing, otherwise false.

setRenderRedirectAfterDispatch

public void setRenderRedirectAfterDispatch(boolean renderRedirectAfterDispatch)
Description copied from class: BridgeContext
Sets a flag indicating whether or not a render-redirect has occurred after dispatching to a JSP.

Specified by:
setRenderRedirectAfterDispatch in class BridgeContext

getRenderRedirectURL

public BridgeRedirectURL getRenderRedirectURL()
Description copied from class: BridgeContext
Gets the render-redirect URL that was set during a render-redirect.

Specified by:
getRenderRedirectURL in class BridgeContext

setRenderRedirectURL

public void setRenderRedirectURL(BridgeRedirectURL renderRedirectURL)
Description copied from class: BridgeContext
Sets the render-redirect URL that is associated with a render-redirect.

Specified by:
setRenderRedirectURL in class BridgeContext

getRequestHeaderMap

public Map<String,String> getRequestHeaderMap()
Specified by:
getRequestHeaderMap in class BridgeContext

getRequestHeaderValuesMap

public Map<String,String[]> getRequestHeaderValuesMap()
Specified by:
getRequestHeaderValuesMap in class BridgeContext

getRequestParameterMap

public Map<String,String> getRequestParameterMap()
Specified by:
getRequestParameterMap in class BridgeContext

getRequestParameterMapFactory

protected RequestParameterMapFactory getRequestParameterMapFactory()

getRequestParameterValuesMap

public Map<String,String[]> getRequestParameterValuesMap()
Specified by:
getRequestParameterValuesMap in class BridgeContext

getRequestPathInfo

public String getRequestPathInfo()
Description copied from class: BridgeContext
Returns the pathInfo associated with the current viewId.

Specified by:
getRequestPathInfo in class BridgeContext

getRequestServletPath

public String getRequestServletPath()
Description copied from class: BridgeContext
Returns the servletPath associated with the current viewId.

Specified by:
getRequestServletPath in class BridgeContext

getResponseNamespace

public String getResponseNamespace()
Specified by:
getResponseNamespace in class BridgeContext

getResponseOutputWriter

public Writer getResponseOutputWriter()
                               throws IOException
Description copied from class: BridgeContext
Returns a Writer that is meant to be used as a return value for ExternalContext.getResponseOutputWriter().

Specified by:
getResponseOutputWriter in class BridgeContext
Throws:
IOException

isPreserveActionParams

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

Specified by:
isPreserveActionParams in class BridgeContext
Returns:
true if the "javax.portlet.faces.preserveActionParams" init-param has a value of true, otherwise false.

getSavedViewState

public String getSavedViewState()
Description copied from class: BridgeContext
Returns the saved view state.

Specified by:
getSavedViewState in class BridgeContext

setSavedViewState

public void setSavedViewState(String savedViewState)
Description copied from class: BridgeContext
Preserves the saved view state.

Specified by:
setSavedViewState in class BridgeContext
Parameters:
savedViewState - The saved view state.

isProcessingAfterViewContent

public boolean isProcessingAfterViewContent()
Description copied from class: BridgeContext
Flag indicating whether or not the bridge is processing Bridge.AFTER_VIEW_CONTENT.

Specified by:
isProcessingAfterViewContent in class BridgeContext
Returns:
true if processing, otherwise false

isRenderRedirect

public boolean isRenderRedirect()
Description copied from class: BridgeContext
Returns the flag indicating whether or not a render redirect occurred.

Specified by:
isRenderRedirect in class BridgeContext


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