Class CmsJspTagLink
- All Implemented Interfaces:
Serializable,javax.servlet.jsp.tagext.BodyTag,javax.servlet.jsp.tagext.IterationTag,javax.servlet.jsp.tagext.JspTag,javax.servlet.jsp.tagext.Tag
<cms:link>[filename]</cms:link>
tag to add OpenCms managed links to a JSP page, required for link
management and the static
export to work properly.- Since:
- 6.0.0
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classParameters for the link tag.static enumLink type. -
Field Summary
Fields inherited from class javax.servlet.jsp.tagext.BodyTagSupport
bodyContentFields inherited from class javax.servlet.jsp.tagext.TagSupport
id, pageContextFields inherited from interface javax.servlet.jsp.tagext.BodyTag
EVAL_BODY_BUFFERED, EVAL_BODY_TAGFields inherited from interface javax.servlet.jsp.tagext.IterationTag
EVAL_BODY_AGAINFields inherited from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintdoEndTag()Returns the base URI used to create the link target.static LocalegetBaseUriLocale(CmsObject cms, String baseUri) Tries to read the active locale for the given (site) path, or for its parent path if the path can't be read.Returns the target detail page path.static StringlinkTagAction(String target, javax.servlet.ServletRequest req) Returns a link to a file in the OpenCms VFS that has been adjusted according to the web application path and the OpenCms static export rules.static StringlinkTagAction(String target, javax.servlet.ServletRequest req, String baseUri) Returns a link to a file in the OpenCms VFS that has been adjusted according to the web application path and the OpenCms static export rules.static StringlinkTagAction(String target, javax.servlet.ServletRequest req, String baseUri, String detailPage, Locale locale) Returns a link to a file in the OpenCms VFS that has been adjusted according to the web application path and the OpenCms static export rules.static StringlinkTagAction(String target, javax.servlet.ServletRequest req, String baseUri, Locale locale) Returns a link to a file in the OpenCms VFS that has been adjusted according to the web application path and the OpenCms static export rules.static StringlinkTagAction(CmsJspTagLink.Parameters params, javax.servlet.ServletRequest req) Returns a link to a file in the OpenCms VFS that has been adjusted according to the web application path and the OpenCms static export rules.voidrelease()voidsetBaseUri(String baseUri) Sets the base URI used to create the link target.voidsetDetailPage(String detailPage) Sets the target detail page path.voidSets the locale for the link to create.voidSets the locale to use for the link.voidSets the scope (only used in combination with the var parameter).voidSets the type.voidsetType(CmsJspTagLink.Type type) Sets the type.voidSets the variable name to store the result in.Methods inherited from class javax.servlet.jsp.tagext.BodyTagSupport
doAfterBody, doInitBody, doStartTag, getBodyContent, getPreviousOut, setBodyContentMethods inherited from class javax.servlet.jsp.tagext.TagSupport
findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setPageContext, setParent, setValueMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface javax.servlet.jsp.tagext.Tag
getParent, setPageContext, setParent
-
Constructor Details
-
CmsJspTagLink
public CmsJspTagLink()
-
-
Method Details
-
getBaseUriLocale
Tries to read the active locale for the given (site) path, or for its parent path if the path can't be read.If this fails, null is returned.
- Parameters:
cms- the CMS contextbaseUri- the base URI for which to read the locale- Returns:
- the locale
-
linkTagAction
public static String linkTagAction(CmsJspTagLink.Parameters params, javax.servlet.ServletRequest req) Returns a link to a file in the OpenCms VFS that has been adjusted according to the web application path and the OpenCms static export rules.If the
baseUriparameter is provided, this will be treated as the source of the link, if this isnullthen the current OpenCms user context URI will be used as source.If the
Relative links are converted to absolute links, using the current element URI as base.localeparameter is provided, the locale in the request context will be switched to the provided locale. This influences only the behavior of theCmsLocalePrefixLinkSubstitutionHandler.- Parameters:
params- TODOreq- the current request- Returns:
- the target link adjusted according to the web application path and the OpenCms static export rules
- Since:
- 8.0.3
- See Also:
-
linkTagAction
Returns a link to a file in the OpenCms VFS that has been adjusted according to the web application path and the OpenCms static export rules.The current OpenCms user context URI will be used as source of the link.
Since OpenCms version 7.0.2, you can also use this method in case you are not sure if the link is internal or external, asCmsLinkManager.substituteLinkForUnknownTarget(org.opencms.file.CmsObject, String)is used to calculate the link target.Relative links are converted to absolute links, using the current element URI as base.
- Parameters:
target- the link that should be calculated, can be relative or absolutereq- the current request- Returns:
- the target link adjusted according to the web application path and the OpenCms static export rules
- See Also:
-
linkTagAction
Returns a link to a file in the OpenCms VFS that has been adjusted according to the web application path and the OpenCms static export rules.If the
Relative links are converted to absolute links, using the current element URI as base.baseUriparameter is provided, this will be treated as the source of the link, if this isnullthen the current OpenCms user context URI will be used as source.- Parameters:
target- the link that should be calculated, can be relative or absolutereq- the current requestbaseUri- the base URI for the link source- Returns:
- the target link adjusted according to the web application path and the OpenCms static export rules
- Since:
- 8.0.3
- See Also:
-
linkTagAction
public static String linkTagAction(String target, javax.servlet.ServletRequest req, String baseUri, Locale locale) Returns a link to a file in the OpenCms VFS that has been adjusted according to the web application path and the OpenCms static export rules.If the
baseUriparameter is provided, this will be treated as the source of the link, if this isnullthen the current OpenCms user context URI will be used as source.If the
Relative links are converted to absolute links, using the current element URI as base.localeparameter is provided, the locale in the request context will be switched to the provided locale. This influences only the behavior of theCmsLocalePrefixLinkSubstitutionHandler.- Parameters:
target- the link that should be calculated, can be relative or absolutereq- the current requestbaseUri- the base URI for the link sourcelocale- the locale for which the link should be created (seeCmsLocalePrefixLinkSubstitutionHandler- Returns:
- the target link adjusted according to the web application path and the OpenCms static export rules
- Since:
- 8.0.3
- See Also:
-
linkTagAction
public static String linkTagAction(String target, javax.servlet.ServletRequest req, String baseUri, String detailPage, Locale locale) Returns a link to a file in the OpenCms VFS that has been adjusted according to the web application path and the OpenCms static export rules.If the
baseUriparameter is provided, this will be treated as the source of the link, if this isnullthen the current OpenCms user context URI will be used as source.If the
Relative links are converted to absolute links, using the current element URI as base.localeparameter is provided, the locale in the request context will be switched to the provided locale. This influences only the behavior of theCmsLocalePrefixLinkSubstitutionHandler.- Parameters:
target- the link that should be calculated, can be relative or absolutereq- the current requestbaseUri- the base URI for the link sourcedetailPage- the target detail page, in case of linking to a specific detail pagelocale- the locale for which the link should be created (seeCmsLocalePrefixLinkSubstitutionHandler- Returns:
- the target link adjusted according to the web application path and the OpenCms static export rules
- Since:
- 8.0.3
- See Also:
-
doEndTag
- Specified by:
doEndTagin interfacejavax.servlet.jsp.tagext.Tag- Overrides:
doEndTagin classjavax.servlet.jsp.tagext.BodyTagSupport- Returns:
- EVAL_PAGE
- Throws:
javax.servlet.jsp.JspException- in case something goes wrong- See Also:
-
getBaseUri
Returns the base URI used to create the link target.- Returns:
- the base URI used to create the link target
-
getDetailPage
Returns the target detail page path.- Returns:
- the target detail page path
-
release
- Specified by:
releasein interfacejavax.servlet.jsp.tagext.Tag- Overrides:
releasein classjavax.servlet.jsp.tagext.BodyTagSupport- See Also:
-
setBaseUri
Sets the base URI used to create the link target.- Parameters:
baseUri- the base URI used to create the link target
-
setDetailPage
Sets the target detail page path.- Parameters:
detailPage- the target detail page path
-
setLocale
Sets the locale to use for the link.- Parameters:
locale- the locale to use for the link
-
setLocale
Sets the locale for the link to create.- Parameters:
localeName- name of the locale, e.g. "en", "en_US", ...
-
setScope
Sets the scope (only used in combination with the var parameter).- Parameters:
scope- the scope for the variable
-
setType
Sets the type.- Parameters:
type- the link type
-
setType
Sets the type.- Parameters:
type- the type
-
setVar
Sets the variable name to store the result in.- Parameters:
var- the variable name to store the result in
-