Class DefaultFriendlyURLMapper
- All Implemented Interfaces:
FriendlyURLMapper
In most cases, to add friendly URL mapping to a portlet, simply set this
class as the friendly URL mapper in liferay-portlet.xml, and
write a friendly-url-routes.xml file.
If you do need to extend this class, the key methods to override are buildPath(LiferayPortletURL) and populateParams(String, Map, Map).
- Author:
- Connor McKay
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionFields inherited from class com.liferay.portal.kernel.portlet.BaseFriendlyURLMapper
router -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a default ignored parameter.voidaddDefaultReservedParameter(String name, String value) Adds a default reserved parameter.protected voidaddParametersIncludedInPath(LiferayPortletURL liferayPortletURL, Map<String, String> routeParameters) Adds the parameters included in the path to the portlet URL.buildPath(LiferayPortletURL liferayPortletURL) Generates a friendly URL path from the portlet URL object.protected voidbuildRouteParameters(LiferayPortletURL liferayPortletURL, Map<String, String> routeParameters) Builds the parameter map to be used by the router by copying parameters from the portlet URL.Returns the default ignored parameters.Returns the default reserved parameters.protected StringgetPortletInstanceKey(Map<String, String> routeParameters) Returns the portlet instance key, including the instance ID if applicable, from the parameter map.protected booleanisAllPublicRenderParameters(Map<String, String> routeParameters) Returnstrueif all the route parameters are public render parameters.voidpopulateParams(String friendlyURLPath, Map<String, String[]> parameterMap, Map<String, Object> requestContext) Populates the parameter map with values parsed from the friendly URL path.protected voidpopulateParams(Map<String, String[]> parameterMap, String namespace, Map<String, String> routeParameters) Populates the parameter map using the parameters from the router and the default reserved parameters.Methods inherited from class com.liferay.portal.kernel.portlet.BaseFriendlyURLMapper
addParameter, addParameter, addParameter, addParameter, addParameter, addParameter, getMapping, getNamespace, getPortletId, getRouter, isCheckMappingWithPrefix, isPortletInstanceable, setMapping, setPortletId, setPortletInstanceable, setRouter
-
Field Details
-
defaultIgnoredParameters
-
defaultReservedParameters
-
-
Constructor Details
-
DefaultFriendlyURLMapper
public DefaultFriendlyURLMapper()
-
-
Method Details
-
addDefaultIgnoredParameter
Adds a default ignored parameter.A default ignored parameter will always be hidden in friendly URLs.
- Parameters:
name- the name of the parameter
-
addDefaultReservedParameter
Adds a default reserved parameter.A default reserved parameter will be hidden in friendly URLs when it is set to its default value.
- Parameters:
name- the name of the parametervalue- the default value of the parameter
-
buildPath
Description copied from interface:FriendlyURLMapperGenerates a friendly URL path from the portlet URL object.- Parameters:
liferayPortletURL- the portlet URL object to generate a friendly URL for- Returns:
- the generated friendly URL, or
nullif one cannot be built. Returningnullwill cause a normal portlet URL to be generated.
-
getDefaultIgnoredParameters
Returns the default ignored parameters.- Returns:
- the ignored parameter names
- See Also:
-
getDefaultReservedParameters
Returns the default reserved parameters.- Returns:
- the default reserved parameter names and values
- See Also:
-
populateParams
public void populateParams(String friendlyURLPath, Map<String, String[]> parameterMap, Map<String, Object> requestContext) Description copied from interface:FriendlyURLMapperPopulates the parameter map with values parsed from the friendly URL path.This method is called by
PortalImplwhen a friendly URL is processed.- Parameters:
friendlyURLPath- the friendly URL path, including a leading slash and the friendly URL mapping. For example:/blogs/example-postparameterMap- the parameter map. Entries added to this map must be namespaced.requestContext- the request context- See Also:
-
addParametersIncludedInPath
protected void addParametersIncludedInPath(LiferayPortletURL liferayPortletURL, Map<String, String> routeParameters) Adds the parameters included in the path to the portlet URL.Portlet URLs track which parameters are included in the friendly URL path. This method hides all the default ignored parameters, the parameters included in the path by the router, and the reserved parameters set to their defaults.
- Parameters:
liferayPortletURL- the portlet URL to which to add the parameters included in the pathrouteParameters- the parameter map populated by the router- See Also:
-
com.liferay.portlet.PortletURLImpl#addParameterIncludedInPath(String)
-
buildRouteParameters
protected void buildRouteParameters(LiferayPortletURL liferayPortletURL, Map<String, String> routeParameters) Builds the parameter map to be used by the router by copying parameters from the portlet URL.This method also populates the special virtual parameters
p_p_idandinstanceIdfor instanceable portlets.- Parameters:
liferayPortletURL- the portlet URL to copy parameters fromrouteParameters- the parameter map to populate for use by the router
-
getPortletInstanceKey
Returns the portlet instance key, including the instance ID if applicable, from the parameter map.- Parameters:
routeParameters- the parameter map. For an instanceable portlet, this must contain eitherp_p_idorinstanceId.- Returns:
- the portlet instance key, including the instance ID if
applicable, or
nullif it cannot be determined
-
isAllPublicRenderParameters
Returnstrueif all the route parameters are public render parameters.- Parameters:
routeParameters- the parameter map- Returns:
trueif all the route parameters are public render parameters;falseotherwise
-
populateParams
protected void populateParams(Map<String, String[]> parameterMap, String namespace, Map<String, String> routeParameters) Populates the parameter map using the parameters from the router and the default reserved parameters.- Parameters:
parameterMap- the parameter map to populate. This should be the map passed topopulateParams(String, Map, Map)byPortalImpl.namespace- the namespace to use for parameters added toparameterMaprouteParameters- the parameter map populated by the router
-