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:
java.io.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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DEFAULT_MAX_ELEMENTS
Default number of max elements in the container in case no value has been set.static java.lang.String
DETAIL_FUNCTION_CONTAINER_NAME
The detail function container name.static java.lang.String
DUMMY_ELEMENT
HTML used for invisible dummy elements.
-
Constructor Summary
Constructors Constructor Description CmsJspTagContainer()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addParameter(java.lang.String name, java.lang.String value)
Add a parameter to this tag.int
doAfterBody()
void
doCatch(java.lang.Throwable t)
int
doEndTag()
void
doFinally()
int
doStartTag()
Internal action method.static I_CmsFormatterBean
ensureValidFormatterSettings(CmsObject cms, CmsContainerElementBean element, CmsADEConfigData adeConfig, java.lang.String containerName, java.lang.String containerType, int containerWidth)
Ensures the appropriate formatter configuration ID is set in the element settings.protected java.lang.String
getContainerData(CmsObject cms, int maxElements, boolean isDetailView, boolean isDetailOnly)
Returns the serialized data of the given container.java.lang.String
getDetailview()
Returns the boolean value if this container is target of detail views.java.lang.String
getEditableby()
Returns the editable by tag attribute.static I_CmsFormatterBean
getFormatterConfigurationForElement(CmsObject cms, CmsContainerElementBean element, CmsADEConfigData adeConfig, java.lang.String containerName, java.lang.String containerType, int containerWidth)
Returns the formatter configuration for the given element.static java.util.List<CmsContainerElementBean>
getGroupContainerElements(CmsObject cms, CmsContainerElementBean element, javax.servlet.ServletRequest req, java.lang.String containerType)
Returns the element group elements.static java.util.List<CmsContainerElementBean>
getInheritedContainerElements(CmsObject cms, CmsContainerElementBean element)
Reads elements from an inherited container.java.lang.String
getMaxElements()
Returns the maxElements attribute value.java.lang.String
getName()
Returns the container name, in case of nested containers with a prefix to guaranty uniqueness.java.lang.String
getNameprefix()
Returns the name prefix.static java.lang.String
getNestedContainerName(java.lang.String name, java.lang.String parentIstanceId, java.lang.String namePrefix)
Returns the prefixed nested container name.java.lang.String
getParam()
Returns the (optional) container parameter.java.lang.String
getTag()
Returns the tag attribute.java.lang.String
getTagClass()
Returns the tag class attribute.protected static java.lang.String
getTagClose(java.lang.String tagName)
Creates the closing tag for the container.protected static java.lang.String
getTagOpen(java.lang.String tagName, java.lang.String containerName, java.lang.String tagClass, boolean nested, boolean online, java.lang.String containerData)
Creates the opening tag for the container assigning the appropriate id and class attributes.java.lang.String
getType()
Returns the type attribute value.java.lang.String
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(java.lang.String cacheable)
Sets the 'cacheable' mode for included formatters.void
setDetailonly(java.lang.String detailOnly)
Sets if this container should only be displayed on detail pages.void
setDetailview(java.lang.String detailView)
Sets if the current container is target of detail views.void
setEditableby(java.lang.String editableBy)
Sets the editable by tag attribute.void
setMaxElements(java.lang.String maxElements)
Sets the maxElements attribute value.void
setName(java.lang.String name)
Sets the name attribute value.void
setNameprefix(java.lang.String namePrefix)
Sets the name prefix.void
setParam(java.lang.String param)
Sets the container parameter.void
setSettings(java.lang.Object presets)
Sets the setting presets.void
setTag(java.lang.String tag)
Sets the tag attribute.void
setTagClass(java.lang.String tagClass)
Sets the tag class attribute.void
setType(java.lang.String type)
Sets the type attribute value.void
setWidth(java.lang.String width)
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
-
-
-
-
Field Detail
-
DEFAULT_MAX_ELEMENTS
public static final java.lang.String DEFAULT_MAX_ELEMENTS
Default number of max elements in the container in case no value has been set.- See Also:
- Constant Field Values
-
DETAIL_FUNCTION_CONTAINER_NAME
public static final java.lang.String DETAIL_FUNCTION_CONTAINER_NAME
The detail function container name.- See Also:
- Constant Field Values
-
DUMMY_ELEMENT
public static final java.lang.String DUMMY_ELEMENT
HTML used for invisible dummy elements.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CmsJspTagContainer
public CmsJspTagContainer()
-
-
Method Detail
-
ensureValidFormatterSettings
public static I_CmsFormatterBean ensureValidFormatterSettings(CmsObject cms, CmsContainerElementBean element, CmsADEConfigData adeConfig, java.lang.String containerName, java.lang.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, java.lang.String containerName, java.lang.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 java.util.List<CmsContainerElementBean> getGroupContainerElements(CmsObject cms, CmsContainerElementBean element, javax.servlet.ServletRequest req, java.lang.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 java.util.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
public static java.lang.String getNestedContainerName(java.lang.String name, java.lang.String parentIstanceId, java.lang.String namePrefix)
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
protected static java.lang.String getTagClose(java.lang.String tagName)
Creates the closing tag for the container.- Parameters:
tagName
- the tag name- Returns:
- the closing tag
-
getTagOpen
protected static java.lang.String getTagOpen(java.lang.String tagName, java.lang.String containerName, java.lang.String tagClass, boolean nested, boolean online, java.lang.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
public void addParameter(java.lang.String name, java.lang.String value)
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:
I_CmsJspTagParamParent.addParameter(java.lang.String, java.lang.String)
-
doAfterBody
public int doAfterBody()
- Specified by:
doAfterBody
in interfacejavax.servlet.jsp.tagext.IterationTag
- Overrides:
doAfterBody
in classjavax.servlet.jsp.tagext.BodyTagSupport
- See Also:
BodyTagSupport.doAfterBody()
-
doCatch
public void doCatch(java.lang.Throwable t) throws java.lang.Throwable
- Specified by:
doCatch
in interfacejavax.servlet.jsp.tagext.TryCatchFinally
- Throws:
java.lang.Throwable
- See Also:
TryCatchFinally.doCatch(java.lang.Throwable)
-
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
- Throws:
javax.servlet.jsp.JspException
- See Also:
TagSupport.doEndTag()
-
doFinally
public void doFinally()
- Specified by:
doFinally
in interfacejavax.servlet.jsp.tagext.TryCatchFinally
- See Also:
TryCatchFinally.doFinally()
-
doStartTag
public int 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
public java.lang.String getDetailview()
Returns the boolean value if this container is target of detail views.- Returns:
true
orfalse
-
getEditableby
public java.lang.String getEditableby()
Returns the editable by tag attribute.- Returns:
- the editable by tag attribute
-
getMaxElements
public java.lang.String getMaxElements()
Returns the maxElements attribute value.- Returns:
- the maxElements attribute value
-
getName
public java.lang.String getName()
Returns the container name, in case of nested containers with a prefix to guaranty uniqueness.- Returns:
- String the container name
-
getNameprefix
public java.lang.String getNameprefix()
Returns the name prefix.- Returns:
- the namePrefix
-
getParam
public java.lang.String 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
public java.lang.String getTag()
Returns the tag attribute.- Returns:
- the tag attribute
-
getTagClass
public java.lang.String getTagClass()
Returns the tag class attribute.- Returns:
- the tag class attribute
-
getType
public java.lang.String 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
public java.lang.String getWidth()
Returns the container width as a string.- Returns:
- the container width as a string
-
setCacheable
public void setCacheable(java.lang.String cacheable)
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
public void setDetailonly(java.lang.String detailOnly)
Sets if this container should only be displayed on detail pages.- Parameters:
detailOnly
- if this container should only be displayed on detail pages
-
setDetailview
public void setDetailview(java.lang.String detailView)
Sets if the current container is target of detail views.- Parameters:
detailView
-true
orfalse
-
setEditableby
public void setEditableby(java.lang.String editableBy)
Sets the editable by tag attribute.- Parameters:
editableBy
- the editable by tag attribute to set
-
setMaxElements
public void setMaxElements(java.lang.String maxElements)
Sets the maxElements attribute value.- Parameters:
maxElements
- the maxElements value to set
-
setName
public void setName(java.lang.String name)
Sets the name attribute value.- Parameters:
name
- the name value to set
-
setNameprefix
public void setNameprefix(java.lang.String namePrefix)
Sets the name prefix.- Parameters:
namePrefix
- the name prefix to set
-
setParam
public void setParam(java.lang.String param)
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
public void setSettings(java.lang.Object presets)
Sets the setting presets.- Parameters:
presets
- a map with string keys and values, or null
-
setTag
public void setTag(java.lang.String tag)
Sets the tag attribute.- Parameters:
tag
- the createTag to set
-
setTagClass
public void setTagClass(java.lang.String tagClass)
Sets the tag class attribute.- Parameters:
tagClass
- the tag class attribute to set
-
setType
public void setType(java.lang.String type)
Sets the type attribute value.- Parameters:
type
- the type value to set
-
setWidth
public void setWidth(java.lang.String width)
Sets the container width as a string.- Parameters:
width
- the container width as a string
-
getContainerData
protected java.lang.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
protected boolean isEditable(CmsObject cms)
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
protected boolean isNested()
Returns true if this is a nested container.- Returns:
- true if this is a nested container
-
printElementWrapperTagEnd
protected void printElementWrapperTagEnd(boolean isGroupcontainer) throws java.io.IOException
Prints the closing tag for an element wrapper if in online mode.- Parameters:
isGroupcontainer
-true
if element is a group-container- Throws:
java.io.IOException
- if the output fails
-
printElementWrapperTagStart
protected void printElementWrapperTagStart(CmsObject cms, CmsContainerElementBean elementBean, CmsContainerPageBean page, boolean isGroupContainer) throws java.lang.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:
java.lang.Exception
- if something goes wrong
-
-