com.liferay.faces.bridge.container.liferay
Class LiferayURLGeneratorBaseImpl

java.lang.Object
  extended by com.liferay.faces.bridge.container.liferay.LiferayURLGeneratorBaseImpl
All Implemented Interfaces:
LiferayURLGenerator
Direct Known Subclasses:
LiferayURLGeneratorActionImpl, LiferayURLGeneratorRenderImpl, LiferayURLGeneratorResourceImpl

public abstract class LiferayURLGeneratorBaseImpl
extends Object
implements LiferayURLGenerator

This abstract class implements the LiferayURLGenerator contract for generating URLs that are compatible with Liferay Portal. The main reason why this is necessary is because the Liferay Portal PortletURLImpl#toString() method returns different values depending on the portlet lifecycle phase during which it is called. Additionally, it sometimes includes the public render parameters in the URL (which are not required for JSF portlets). Another issue is related to ICEfaces, which uses a server-side DOM-diff algorithm within it's RenderKit. When DOM-diff strategies are used, it is critical that URLs always be the same regardless of which portlet lifecycle phase is executing. For example, a URL generated during the PortletRequest.RENDER_PHASE of the portlet lifecycle must be identical to the one generated during the PortletRequest.RESOURCE_PHASE, or else a DOM-diff will be detected.

The constructors of this class receive a String-based parameter named "baseURL" which is expected to be the result of calling the toString() method of a Liferay URL. The baseURL is then parsed and the URL parameters are cached so that the generateURL(Map) method can quickly generate a consistent URL.

Author:
Neil Griffin

Constructor Summary
LiferayURLGeneratorBaseImpl(String baseURL, javax.portlet.PortletMode portletMode, String responseNamespace, javax.portlet.WindowState windowState)
          Constructs a new instance.
LiferayURLGeneratorBaseImpl(String baseURL, String responseNamespace)
          Constructs a new instance.
 
Method Summary
protected  void appendParameterToURL(boolean firstParameter, boolean namespaced, String parameterName, String parameterValue, StringBuilder url)
           
protected  void appendParameterToURL(boolean firstParameter, String parameterName, String parameterValue, StringBuilder url)
           
protected  void appendParameterToURL(String parameterName, String parameterValue, StringBuilder url)
           
protected  String encode(String value)
           
 String generateURL(Map<String,String[]> additionalParameterMap)
          Generates a Liferay-compatible URL with the specified additional URL parameters.
 String generateURL(Map<String,String[]> additionalParameterMap, javax.portlet.PortletMode portletMode, String resourceId, javax.portlet.WindowState windowState)
           
 String generateURL(Map<String,String[]> additionalParameterMap, javax.portlet.PortletMode portletMode, javax.portlet.WindowState windowState)
          Generates a Liferay-compatible URL with the specified additional URL parameters, portlet mode, and window state.
 String generateURL(Map<String,String[]> additionalParameterMap, String resourceId)
          Generates a Liferay-compatible URL with the specified additional URL parameters and resource ID.
protected  void parse()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.liferay.faces.bridge.container.liferay.LiferayURLGenerator
getPortletLifecycleId
 

Constructor Detail

LiferayURLGeneratorBaseImpl

public LiferayURLGeneratorBaseImpl(String baseURL,
                                   String responseNamespace)
Constructs a new instance.

Parameters:
baseURL - The String-based URL generated by Liferay Portal's PortletURLImpl#toString() method.
responseNamespace - The response namespace.

LiferayURLGeneratorBaseImpl

public LiferayURLGeneratorBaseImpl(String baseURL,
                                   javax.portlet.PortletMode portletMode,
                                   String responseNamespace,
                                   javax.portlet.WindowState windowState)
Constructs a new instance.

Parameters:
baseURL - The String-based URL generated by Liferay Portal's PortletURLImpl#toString() method.
portletMode - The portlet mode specified by Liferay Portal's PortletURLImpl#getPortletMode() method.
responseNamespace - The response namespace.
windowState - The window state specified by Liferay Portal's PortletURLImpl#getWindowState() method.
Method Detail

generateURL

public String generateURL(Map<String,String[]> additionalParameterMap)
Description copied from interface: LiferayURLGenerator
Generates a Liferay-compatible URL with the specified additional URL parameters.

Specified by:
generateURL in interface LiferayURLGenerator
Parameters:
additionalParameterMap - Additional URL parameters.
Returns:
The Liferay-compatible URL.

generateURL

public String generateURL(Map<String,String[]> additionalParameterMap,
                          String resourceId)
Description copied from interface: LiferayURLGenerator
Generates a Liferay-compatible URL with the specified additional URL parameters and resource ID.

Specified by:
generateURL in interface LiferayURLGenerator
Parameters:
additionalParameterMap - Additional URL parameters.
resourceId - The resource ID.
Returns:
The Liferay-compatible URL.

generateURL

public String generateURL(Map<String,String[]> additionalParameterMap,
                          javax.portlet.PortletMode portletMode,
                          javax.portlet.WindowState windowState)
Description copied from interface: LiferayURLGenerator
Generates a Liferay-compatible URL with the specified additional URL parameters, portlet mode, and window state.

Specified by:
generateURL in interface LiferayURLGenerator
Parameters:
additionalParameterMap - Additional URL parameters.
portletMode - The portlet mode.
windowState - The window state.
Returns:

generateURL

public String generateURL(Map<String,String[]> additionalParameterMap,
                          javax.portlet.PortletMode portletMode,
                          String resourceId,
                          javax.portlet.WindowState windowState)

appendParameterToURL

protected void appendParameterToURL(String parameterName,
                                    String parameterValue,
                                    StringBuilder url)

appendParameterToURL

protected void appendParameterToURL(boolean firstParameter,
                                    String parameterName,
                                    String parameterValue,
                                    StringBuilder url)

appendParameterToURL

protected void appendParameterToURL(boolean firstParameter,
                                    boolean namespaced,
                                    String parameterName,
                                    String parameterValue,
                                    StringBuilder url)

encode

protected String encode(String value)

parse

protected void parse()


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