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 class
Parameters for the link tag.static enum
Link type. -
Field Summary
Fields inherited from class javax.servlet.jsp.tagext.BodyTagSupport
bodyContent
Fields inherited from class javax.servlet.jsp.tagext.TagSupport
id, pageContext
Fields inherited from interface javax.servlet.jsp.tagext.BodyTag
EVAL_BODY_BUFFERED, EVAL_BODY_TAG
Fields inherited from interface javax.servlet.jsp.tagext.IterationTag
EVAL_BODY_AGAIN
Fields inherited from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
doEndTag()
Returns the base URI used to create the link target.static Locale
getBaseUriLocale
(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 String
linkTagAction
(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 String
linkTagAction
(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 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.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.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.void
release()
void
setBaseUri
(String baseUri) Sets the base URI used to create the link target.void
setDetailPage
(String detailPage) Sets the target detail page path.void
Sets the locale for the link to create.void
Sets the locale to use for the link.void
Sets the scope (only used in combination with the var parameter).void
Sets the type.void
setType
(CmsJspTagLink.Type type) Sets the type.void
Sets the variable name to store the result in.Methods inherited from class javax.servlet.jsp.tagext.BodyTagSupport
doAfterBody, doInitBody, doStartTag, getBodyContent, getPreviousOut, setBodyContent
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setPageContext, setParent, setValue
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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
baseUri
parameter is provided, this will be treated as the source of the link, if this isnull
then 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.locale
parameter 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.baseUri
parameter is provided, this will be treated as the source of the link, if this isnull
then 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
baseUri
parameter is provided, this will be treated as the source of the link, if this isnull
then 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.locale
parameter 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
baseUri
parameter is provided, this will be treated as the source of the link, if this isnull
then 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.locale
parameter 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:
doEndTag
in interfacejavax.servlet.jsp.tagext.Tag
- Overrides:
doEndTag
in classjavax.servlet.jsp.tagext.BodyTagSupport
- Returns:
- EVAL_PAGE
- Throws:
javax.servlet.jsp.JspException
- in case something goes wrong- See Also:
-
Tag.doEndTag()
-
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:
release
in interfacejavax.servlet.jsp.tagext.Tag
- Overrides:
release
in classjavax.servlet.jsp.tagext.BodyTagSupport
- See Also:
-
Tag.release()
-
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
-