Package org.opencms.jsp
Class CmsJspTagContainer
java.lang.Object
javax.servlet.jsp.tagext.TagSupport
javax.servlet.jsp.tagext.BodyTagSupport
org.opencms.jsp.CmsJspTagContainer
- All Implemented Interfaces:
Serializable
,javax.servlet.jsp.tagext.BodyTag
,javax.servlet.jsp.tagext.IterationTag
,javax.servlet.jsp.tagext.JspTag
,javax.servlet.jsp.tagext.Tag
,javax.servlet.jsp.tagext.TryCatchFinally
,I_CmsJspTagParamParent
public class CmsJspTagContainer
extends javax.servlet.jsp.tagext.BodyTagSupport
implements javax.servlet.jsp.tagext.TryCatchFinally, I_CmsJspTagParamParent
Provides access to the page container elements.
- Since:
- 8.0
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Default number of max elements in the container in case no value has been set.static final String
The detail function container name.static final String
HTML used for invisible dummy elements.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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addParameter
(String name, String value) Add a parameter to this tag.int
void
int
doEndTag()
void
int
Internal action method.static I_CmsFormatterBean
ensureValidFormatterSettings
(CmsObject cms, CmsContainerElementBean element, CmsADEConfigData adeConfig, String containerName, String containerType, int containerWidth) Ensures the appropriate formatter configuration ID is set in the element settings.protected String
getContainerData
(CmsObject cms, int maxElements, boolean isDetailView, boolean isDetailOnly) Returns the serialized data of the given container.Returns the boolean value if this container is target of detail views.Returns the editable by tag attribute.static I_CmsFormatterBean
getFormatterConfigurationForElement
(CmsObject cms, CmsContainerElementBean element, CmsADEConfigData adeConfig, String containerName, String containerType, int containerWidth) Returns the formatter configuration for the given element.static List<CmsContainerElementBean>
getGroupContainerElements
(CmsObject cms, CmsContainerElementBean element, javax.servlet.ServletRequest req, String containerType) Returns the element group elements.static List<CmsContainerElementBean>
getInheritedContainerElements
(CmsObject cms, CmsContainerElementBean element) Reads elements from an inherited container.Returns the maxElements attribute value.getName()
Returns the container name, in case of nested containers with a prefix to guaranty uniqueness.Returns the name prefix.static String
getNestedContainerName
(String name, String parentIstanceId, String namePrefix) Returns the prefixed nested container name.getParam()
Returns the (optional) container parameter.getTag()
Returns the tag attribute.Returns the tag class attribute.protected static String
getTagClose
(String tagName) Creates the closing tag for the container.protected static String
getTagOpen
(String tagName, String containerName, String tagClass, boolean nested, boolean online, String containerData) Creates the opening tag for the container assigning the appropriate id and class attributes.getType()
Returns the type attribute value.getWidth()
Returns the container width as a string.protected boolean
isEditable
(CmsObject cms) Returns if the container is editable by the current user.protected boolean
isNested()
Returns true if this is a nested container.protected void
printElementWrapperTagEnd
(boolean isGroupcontainer) Prints the closing tag for an element wrapper if in online mode.protected void
printElementWrapperTagStart
(CmsObject cms, CmsContainerElementBean elementBean, CmsContainerPageBean page, boolean isGroupContainer) Prints the opening element wrapper tag for the container page editor if we are in Offline mode.void
setCacheable
(String cacheable) Sets the 'cacheable' mode for included formatters.void
setDetailonly
(String detailOnly) Sets if this container should only be displayed on detail pages.void
setDetailview
(String detailView) Sets if the current container is target of detail views.void
setEditableby
(String editableBy) Sets the editable by tag attribute.void
setMaxElements
(String maxElements) Sets the maxElements attribute value.void
Sets the name attribute value.void
setNameprefix
(String namePrefix) Sets the name prefix.void
Sets the container parameter.void
setSettings
(Object presets) Sets the setting presets.void
Sets the tag attribute.void
setTagClass
(String tagClass) Sets the tag class attribute.void
Sets the type attribute value.void
Sets the container width as a string.Methods inherited from class javax.servlet.jsp.tagext.BodyTagSupport
doInitBody, getBodyContent, getPreviousOut, release, 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
-
Field Details
-
DEFAULT_MAX_ELEMENTS
Default number of max elements in the container in case no value has been set.- See Also:
-
DETAIL_FUNCTION_CONTAINER_NAME
The detail function container name.- See Also:
-
DUMMY_ELEMENT
HTML used for invisible dummy elements.- See Also:
-
-
Constructor Details
-
CmsJspTagContainer
public CmsJspTagContainer()
-
-
Method Details
-
ensureValidFormatterSettings
public static I_CmsFormatterBean ensureValidFormatterSettings(CmsObject cms, CmsContainerElementBean element, CmsADEConfigData adeConfig, String containerName, String containerType, int containerWidth) Ensures the appropriate formatter configuration ID is set in the element settings.- Parameters:
cms
- the cms contextelement
- the element beanadeConfig
- the ADE configuration datacontainerName
- the container namecontainerType
- the container typecontainerWidth
- the container width- Returns:
- the formatter configuration bean, may be
null
if no formatter available or a schema formatter is used
-
getFormatterConfigurationForElement
public static I_CmsFormatterBean getFormatterConfigurationForElement(CmsObject cms, CmsContainerElementBean element, CmsADEConfigData adeConfig, String containerName, String containerType, int containerWidth) Returns the formatter configuration for the given element.- Parameters:
cms
- the cms contextelement
- the element beanadeConfig
- the ADE configurationcontainerName
- the container namecontainerType
- the container typecontainerWidth
- the container width- Returns:
- the formatter configuration
-
getGroupContainerElements
public static List<CmsContainerElementBean> getGroupContainerElements(CmsObject cms, CmsContainerElementBean element, javax.servlet.ServletRequest req, String containerType) throws CmsException Returns the element group elements.- Parameters:
cms
- the current cms contextelement
- group elementreq
- the servlet requestcontainerType
- the container type- Returns:
- the elements of this group
- Throws:
CmsException
- if something goes wrong
-
getInheritedContainerElements
public static List<CmsContainerElementBean> getInheritedContainerElements(CmsObject cms, CmsContainerElementBean element) Reads elements from an inherited container.- Parameters:
cms
- the current CMS contextelement
- the element which references the inherited container- Returns:
- the container elements
-
getNestedContainerName
Returns the prefixed nested container name.This will be either {parentInstanceId}-{name} or {namePrefix}-{name} or in case namePrefix equals 'none' {name} only.
- Parameters:
name
- the container nameparentIstanceId
- the parent instance idnamePrefix
- the name prefix attribute- Returns:
- the nested container name
-
getTagClose
Creates the closing tag for the container.- Parameters:
tagName
- the tag name- Returns:
- the closing tag
-
getTagOpen
protected static String getTagOpen(String tagName, String containerName, String tagClass, boolean nested, boolean online, String containerData) Creates the opening tag for the container assigning the appropriate id and class attributes.- Parameters:
tagName
- the tag namecontainerName
- the container name used as id attribute valuetagClass
- the tag class attribute valuenested
- true if this is a nested containeronline
- true if we are in the online projectcontainerData
- the container data- Returns:
- the opening tag
-
addParameter
Description copied from interface:I_CmsJspTagParamParent
Add a parameter to this tag. The intent is that the <param> subtag will call this to register parameters. Assumes that 'name' and 'value' are appropriately encoded and do not contain any meaningful metacharacters; in order words, escaping is the responsibility of the caller.- Specified by:
addParameter
in interfaceI_CmsJspTagParamParent
- Parameters:
name
- the name of the parametervalue
- the value of the parameter- See Also:
-
doAfterBody
- Specified by:
doAfterBody
in interfacejavax.servlet.jsp.tagext.IterationTag
- Overrides:
doAfterBody
in classjavax.servlet.jsp.tagext.BodyTagSupport
- See Also:
-
BodyTagSupport.doAfterBody()
-
doCatch
- Specified by:
doCatch
in interfacejavax.servlet.jsp.tagext.TryCatchFinally
- Throws:
Throwable
- See Also:
-
TryCatchFinally.doCatch(java.lang.Throwable)
-
doEndTag
- Specified by:
doEndTag
in interfacejavax.servlet.jsp.tagext.Tag
- Overrides:
doEndTag
in classjavax.servlet.jsp.tagext.BodyTagSupport
- Throws:
javax.servlet.jsp.JspException
- See Also:
-
TagSupport.doEndTag()
-
doFinally
- Specified by:
doFinally
in interfacejavax.servlet.jsp.tagext.TryCatchFinally
- See Also:
-
TryCatchFinally.doFinally()
-
doStartTag
Internal action method.- Specified by:
doStartTag
in interfacejavax.servlet.jsp.tagext.Tag
- Overrides:
doStartTag
in classjavax.servlet.jsp.tagext.BodyTagSupport
- Returns:
- EVAL_BODY_BUFFERED
- See Also:
-
Tag.doStartTag()
-
getDetailview
Returns the boolean value if this container is target of detail views.- Returns:
true
orfalse
-
getEditableby
Returns the editable by tag attribute.- Returns:
- the editable by tag attribute
-
getMaxElements
Returns the maxElements attribute value.- Returns:
- the maxElements attribute value
-
getName
Returns the container name, in case of nested containers with a prefix to guaranty uniqueness.- Returns:
- String the container name
-
getNameprefix
Returns the name prefix.- Returns:
- the namePrefix
-
getParam
Returns the (optional) container parameter.This is useful for a dynamically generated nested container, to pass information to the formatter used inside that container. If no parameters have been set, this will return
null
- Returns:
- the (optional) container parameter
-
getTag
Returns the tag attribute.- Returns:
- the tag attribute
-
getTagClass
Returns the tag class attribute.- Returns:
- the tag class attribute
-
getType
Returns the type attribute value.If the container type has not been set, the name is substituted as type.
- Returns:
- the type attribute value
-
getWidth
Returns the container width as a string.- Returns:
- the container width as a string
-
setCacheable
Sets the 'cacheable' mode for included formatters.If this is set to false, formatters will never be included in cacheable mode, otherwise they will only be included in cacheable mode in the Online project.
- Parameters:
cacheable
- the cacheable mode (true or false)
-
setDetailonly
Sets if this container should only be displayed on detail pages.- Parameters:
detailOnly
- if this container should only be displayed on detail pages
-
setDetailview
Sets if the current container is target of detail views.- Parameters:
detailView
-true
orfalse
-
setEditableby
Sets the editable by tag attribute.- Parameters:
editableBy
- the editable by tag attribute to set
-
setMaxElements
Sets the maxElements attribute value.- Parameters:
maxElements
- the maxElements value to set
-
setName
Sets the name attribute value.- Parameters:
name
- the name value to set
-
setNameprefix
Sets the name prefix.- Parameters:
namePrefix
- the name prefix to set
-
setParam
Sets the container parameter.This is useful for a dynamically generated nested container, to pass information to the formatter used inside that container.
- Parameters:
param
- the parameter String to set
-
setSettings
Sets the setting presets.- Parameters:
presets
- a map with string keys and values, or null
-
setTag
Sets the tag attribute.- Parameters:
tag
- the createTag to set
-
setTagClass
Sets the tag class attribute.- Parameters:
tagClass
- the tag class attribute to set
-
setType
Sets the type attribute value.- Parameters:
type
- the type value to set
-
setWidth
Sets the container width as a string.- Parameters:
width
- the container width as a string
-
getContainerData
protected String getContainerData(CmsObject cms, int maxElements, boolean isDetailView, boolean isDetailOnly) Returns the serialized data of the given container.- Parameters:
cms
- the cms contextmaxElements
- the maximum number of elements allowed within this containerisDetailView
-true
if this container is currently being used for the detail viewisDetailOnly
-true
if this is a detail only container- Returns:
- the serialized container data
-
isEditable
Returns if the container is editable by the current user.- Parameters:
cms
- the cms context- Returns:
true
if the container is editable by the current user
-
isNested
Returns true if this is a nested container.- Returns:
- true if this is a nested container
-
printElementWrapperTagEnd
Prints the closing tag for an element wrapper if in online mode.- Parameters:
isGroupcontainer
-true
if element is a group-container- Throws:
IOException
- if the output fails
-
printElementWrapperTagStart
protected void printElementWrapperTagStart(CmsObject cms, CmsContainerElementBean elementBean, CmsContainerPageBean page, boolean isGroupContainer) throws Exception Prints the opening element wrapper tag for the container page editor if we are in Offline mode.- Parameters:
cms
- the Cms contextelementBean
- the element beanpage
- the container pageisGroupContainer
- true if the element is a group-container- Throws:
Exception
- if something goes wrong
-