Class CmsJspTagLink
- java.lang.Object
-
- javax.servlet.jsp.tagext.TagSupport
-
- javax.servlet.jsp.tagext.BodyTagSupport
-
- org.opencms.jsp.CmsJspTagLink
-
- All Implemented Interfaces:
java.io.Serializable
,javax.servlet.jsp.tagext.BodyTag
,javax.servlet.jsp.tagext.IterationTag
,javax.servlet.jsp.tagext.JspTag
,javax.servlet.jsp.tagext.Tag
public class CmsJspTagLink extends javax.servlet.jsp.tagext.BodyTagSupport
Implements the<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:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CmsJspTagLink.Parameters
Parameters for the link tag.static class
CmsJspTagLink.Type
Link type.
-
Constructor Summary
Constructors Constructor Description CmsJspTagLink()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
doEndTag()
java.lang.String
getBaseUri()
Returns the base URI used to create the link target.static java.util.Locale
getBaseUriLocale(CmsObject cms, java.lang.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.java.lang.String
getDetailPage()
Returns the target detail page path.static java.lang.String
linkTagAction(java.lang.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 java.lang.String
linkTagAction(java.lang.String target, javax.servlet.ServletRequest req, java.lang.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 java.lang.String
linkTagAction(java.lang.String target, javax.servlet.ServletRequest req, java.lang.String baseUri, java.lang.String detailPage, java.util.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 java.lang.String
linkTagAction(java.lang.String target, javax.servlet.ServletRequest req, java.lang.String baseUri, java.util.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 java.lang.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(java.lang.String baseUri)
Sets the base URI used to create the link target.void
setDetailPage(java.lang.String detailPage)
Sets the target detail page path.void
setLocale(java.lang.String localeName)
Sets the locale for the link to create.void
setLocale(java.util.Locale locale)
Sets the locale to use for the link.void
setScope(java.lang.String scope)
Sets the scope (only used in combination with the var parameter).void
setType(java.lang.String type)
Sets the type.void
setType(CmsJspTagLink.Type type)
Sets the type.void
setVar(java.lang.String var)
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
-
-
-
-
Constructor Detail
-
CmsJspTagLink
public CmsJspTagLink()
-
-
Method Detail
-
getBaseUriLocale
public static java.util.Locale getBaseUriLocale(CmsObject cms, java.lang.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.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 java.lang.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(String, ServletRequest)
-
linkTagAction
public static java.lang.String linkTagAction(java.lang.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.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:
CmsLinkManager.substituteLinkForUnknownTarget(org.opencms.file.CmsObject, String)
-
linkTagAction
public static java.lang.String linkTagAction(java.lang.String target, javax.servlet.ServletRequest req, java.lang.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.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(String, ServletRequest)
-
linkTagAction
public static java.lang.String linkTagAction(java.lang.String target, javax.servlet.ServletRequest req, java.lang.String baseUri, java.util.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(String, ServletRequest)
-
linkTagAction
public static java.lang.String linkTagAction(java.lang.String target, javax.servlet.ServletRequest req, java.lang.String baseUri, java.lang.String detailPage, java.util.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:
linkTagAction(String, ServletRequest)
-
doEndTag
public int doEndTag() throws javax.servlet.jsp.JspException
- 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
public java.lang.String getBaseUri()
Returns the base URI used to create the link target.- Returns:
- the base URI used to create the link target
-
getDetailPage
public java.lang.String getDetailPage()
Returns the target detail page path.- Returns:
- the target detail page path
-
release
public void release()
- Specified by:
release
in interfacejavax.servlet.jsp.tagext.Tag
- Overrides:
release
in classjavax.servlet.jsp.tagext.BodyTagSupport
- See Also:
Tag.release()
-
setBaseUri
public void setBaseUri(java.lang.String baseUri)
Sets the base URI used to create the link target.- Parameters:
baseUri
- the base URI used to create the link target
-
setDetailPage
public void setDetailPage(java.lang.String detailPage)
Sets the target detail page path.- Parameters:
detailPage
- the target detail page path
-
setLocale
public void setLocale(java.util.Locale locale)
Sets the locale to use for the link.- Parameters:
locale
- the locale to use for the link
-
setLocale
public void setLocale(java.lang.String localeName)
Sets the locale for the link to create.- Parameters:
localeName
- name of the locale, e.g. "en", "en_US", ...
-
setScope
public void setScope(java.lang.String scope)
Sets the scope (only used in combination with the var parameter).- Parameters:
scope
- the scope for the variable
-
setType
public void setType(java.lang.String type)
Sets the type.- Parameters:
type
- the link type
-
setType
public void setType(CmsJspTagLink.Type type)
Sets the type.- Parameters:
type
- the type
-
setVar
public void setVar(java.lang.String var)
Sets the variable name to store the result in.- Parameters:
var
- the variable name to store the result in
-
-