Interface ComponentContext


  • public interface ComponentContext
    A 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 in edit mode and if the components are editable it also provides an EditContext. 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 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 or null if 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:
        true if 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 null if 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 in WCMMode.EDIT or WCMMode.DESIGN null is 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 in WCMMode.ANALYTICS, null is returned.
        Returns:
        analyze context or null
      • getComponent

        Component getComponent()
        Returns the top most component that is associated with this context.
        Returns:
        the component or null if 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 null if 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 is null it is removed from the attribute map.
        Parameters:
        name - the name of the attribute
        value - 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:
        true if this context needs decoration
      • setDecorate

        void setDecorate​(boolean decorate)
        Sets if this context needs decoration.
        Parameters:
        decorate - true if 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 to null the 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 to null it 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 to div.
        Parameters:
        decorationTagName - the name of the decoration tag.
        Since:
        5.3
        See Also:
        setDecorationTagName(String), Component.getHtmlTagAttributes(), IncludeOptions.setDecorationTagName(String)