Package com.day.cq.wcm.api.components
Interface ComponentContext
-
public interface ComponentContextA component context is opened for each component include that provides a new cell on the cell stack. this is usually the case if the cell name is not empty. The component context is independent from the WCM mode and is always available to the scripts. If the WCM is ineditmode and if the components are editable it also provides anEditContext. Note that an edit context can span several component contexts if not all of the components that are included provide editing. for example pure general purpose scripts.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringBYPASS_COMPONENT_HANDLING_ON_INCLUDE_ATTRIBUTEname of the request attribute to bypass component handling.static java.lang.StringCONTEXT_ATTR_NAMERequest attribute name for retrieving the current context
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description AnalyzeContextgetAnalyzeContext()Returns the analyze context for this include.java.lang.ObjectgetAttribute(java.lang.String name)Returns the context attribute for the given nameCellgetCell()Returns the design cell.ComponentgetComponent()Returns the top most component that is associated with this context.java.util.Set<java.lang.String>getCssClassNames()Returns the set of css class names to be added to the html tag.java.lang.StringgetDecorationTagName()Returns the decoration tag name.java.lang.StringgetDefaultDecorationTagName()Returns the default decoration tag name.EditContextgetEditContext()Returns the edit context for this include.PagegetPage()Returns the page this component context is operating on.ComponentContextgetParent()Returns the parent context ornullif this context is the root context.ResourcegetResource()Returns the top most resource that is associated with this context.ComponentContextgetRoot()Returns the root context.booleanhasDecoration()Checks if this contexts needs decoration at all.booleanisRoot()Checks if this is the root context.java.lang.ObjectsetAttribute(java.lang.String name, java.lang.Object value)Sets a context attribute with the given name.voidsetDecorate(boolean decorate)Sets if this context needs decoration.voidsetDecorationTagName(java.lang.String decorationTagName)Sets the decoration tag name.voidsetDefaultDecorationTagName(java.lang.String decorationTagName)Sets the default decoration tag name.
-
-
-
Field Detail
-
CONTEXT_ATTR_NAME
static final java.lang.String CONTEXT_ATTR_NAME
Request attribute name for retrieving the current context- See Also:
- Constant Field Values
-
BYPASS_COMPONENT_HANDLING_ON_INCLUDE_ATTRIBUTE
static final java.lang.String BYPASS_COMPONENT_HANDLING_ON_INCLUDE_ATTRIBUTE
name of the request attribute to bypass component handling.
-
-
Method Detail
-
getParent
ComponentContext getParent()
Returns the parent context ornullif this context is the root context.- Returns:
- the parent context or
null
-
getRoot
ComponentContext getRoot()
Returns the root context.- Returns:
- the root context.
-
isRoot
boolean isRoot()
Checks if this is the root context.- Returns:
trueif this is the root context
-
getResource
Resource getResource()
Returns the top most resource that is associated with this context. it can occur that a component context spans several resources if a resource of a sub include does not define a new cell.- Returns:
- the resource or
nullif not bound.
-
getCell
Cell getCell()
Returns the design cell.- Returns:
- the design cell.
-
getEditContext
EditContext getEditContext()
Returns the edit context for this include. If the respective component is not editable/designable or if the WCM is not inWCMMode.EDITorWCMMode.DESIGNnullis returned. Please note that for different component contexts, the same edit context can be returned, if the respective component spans several includes.- Returns:
- edit context or
null
-
getAnalyzeContext
AnalyzeContext getAnalyzeContext()
Returns the analyze context for this include. If the respective component is not analyzable or if the WCM is not inWCMMode.ANALYTICS,nullis returned.- Returns:
- analyze context or
null
-
getComponent
Component getComponent()
Returns the top most component that is associated with this context.- Returns:
- the component or
nullif not bound.
-
getPage
Page getPage()
Returns the page this component context is operating on.- Returns:
- the page.
-
getAttribute
java.lang.Object getAttribute(java.lang.String name)
Returns the context attribute for the given name- Parameters:
name- the name of the attribute- Returns:
- the attribute or
nullif not defined.
-
setAttribute
java.lang.Object setAttribute(java.lang.String name, java.lang.Object value)Sets a context attribute with the given name. If the given attribute isnullit is removed from the attribute map.- Parameters:
name- the name of the attributevalue- the attribute value- Returns:
- the old attribute or
null
-
getCssClassNames
java.util.Set<java.lang.String> getCssClassNames()
Returns the set of css class names to be added to the html tag. note that the names from the include options are only added when the context is included.- Returns:
- the set of css class names
-
hasDecoration
boolean hasDecoration()
Checks if this contexts needs decoration at all.- Returns:
trueif this context needs decoration
-
setDecorate
void setDecorate(boolean decorate)
Sets if this context needs decoration.- Parameters:
decorate-trueif decoration should be drawn
-
getDecorationTagName
java.lang.String getDecorationTagName()
Returns the decoration tag name.- Returns:
- the decoration tag name
- Since:
- 5.3
- See Also:
setDecorationTagName(String)
-
setDecorationTagName
void setDecorationTagName(java.lang.String decorationTagName)
Sets the decoration tag name. if set tonullthe default name will be used, if set to an empty string, no decoration tag is rendered. the tag name is initialized by the "cq:tagName" property of the "cq:htmlTag" node of the component definition, unless it is overriden by a include option.- Parameters:
decorationTagName- the name of the decoration tag.- Since:
- 5.3
- See Also:
setDefaultDecorationTagName(String),Component.getHtmlTagAttributes(),IncludeOptions.setDecorationTagName(String)
-
getDefaultDecorationTagName
java.lang.String getDefaultDecorationTagName()
Returns the default decoration tag name.- Returns:
- the default decoration tag name
- Since:
- 5.3
- See Also:
setDefaultDecorationTagName(String)
-
setDefaultDecorationTagName
void setDefaultDecorationTagName(java.lang.String decorationTagName)
Sets the default decoration tag name. if set tonullit will be inherited from the parent context, if set to an empty string, no decoration tag is rendered. the default tag name is used if non is provided by the component or set via include options. it defaults todiv.- Parameters:
decorationTagName- the name of the decoration tag.- Since:
- 5.3
- See Also:
setDecorationTagName(String),Component.getHtmlTagAttributes(),IncludeOptions.setDecorationTagName(String)
-
-