Class HtmlElement<T extends HtmlElement>

    • Constructor Detail

      • HtmlElement

        public HtmlElement​(String name)
        Initializes html element.
        Parameters:
        name - Element name
    • Method Detail

      • add

        public final <HtmlElementType extends HtmlElement> HtmlElementType add​(HtmlElementType element)
        Appends the child to the end of the element's content list. Returns not the element itself (contrary to addContent), but a reference to the newly added element.
        Type Parameters:
        HtmlElementType - Type that extends HtmlElement
        Parameters:
        element - Element to add. Null values are ignored.
        Returns:
        The added element.
      • getEmptyAttributeValueAsBoolean

        protected final boolean getEmptyAttributeValueAsBoolean​(String attributeName)
        Gets "empty" attribute value as boolean (i.e. for "checked" attribute).
        Parameters:
        attributeName - Attribute name
        Returns:
        Attribute value as boolean or false if not set.
      • setEmptyAttributeValueAsBoolean

        protected final T setEmptyAttributeValueAsBoolean​(String attributeName,
                                                          boolean value)
        Sets "empty" attribute value as boolean (i.e. for "checked" attribute).
        Parameters:
        attributeName - Attribute name
        value - Attribute value as boolean
        Returns:
        Self reference
      • getId

        public final String getId()
        Html "id" attribute.
        Returns:
        Value of attribute
      • setId

        public final T setId​(String value)
        Html "id" attribute.
        Parameters:
        value - Value of attribute
        Returns:
        Self reference
      • getCssClass

        public final String getCssClass()
        Html "class" attribute.
        Returns:
        Value of attribute
      • setCssClass

        public final T setCssClass​(String value)
        Sets Html "class" attribute - unless you're really sure that you want to replace existing classes, you probably should call addCssClass(String) instead.
        Parameters:
        value - Value of attribute
        Returns:
        Self reference
      • addCssClass

        public final T addCssClass​(String value)
        Html "class" attribute. Adds a single, space-separated value while preserving existing ones.
        Parameters:
        value - Value of attribute
        Returns:
        Self reference
      • getStyleString

        public final String getStyleString()
        Html "style" attribute.
        Returns:
        Value of attribute with style key/value pairs
      • getStyles

        public final Map<String,​String> getStyles()
        Html "style" attribute.
        Returns:
        Returns map of style key/value pairs.
      • getStyle

        public final String getStyle​(String styleAttribute)
        Html "style" attribute. Returns single style attribute value.
        Parameters:
        styleAttribute - Style attribute name
        Returns:
        Style attribute value
      • setStyleString

        public final T setStyleString​(String value)
        Html "style" attribute.
        Parameters:
        value - Value of attribute with style key/value pairs
        Returns:
        Self reference
      • setStyle

        public final T setStyle​(String styleAttribute,
                                String styleValue)
        Html "style" attribute. Sets single style attribute value.
        Parameters:
        styleAttribute - Style attribute name
        styleValue - Style attribute value
        Returns:
        Self reference
      • getTitle

        public final String getTitle()
        Html "title" attribute.
        Returns:
        Value of attribute
      • setTitle

        public final T setTitle​(String value)
        Html "title" attribute.
        Parameters:
        value - Value of attribute
        Returns:
        Self reference
      • getData

        public final String getData​(String attributeName)
        Custom Html5 "data-*" attribute.
        Parameters:
        attributeName - Name of HTML5 data attribute (without the 'data-' prefix).
        Returns:
        Value of attribute
      • setData

        public final T setData​(String attributeName,
                               String value)
        Custom Html5 "data-*" attribute.
        Parameters:
        attributeName - Name of HTML5 data attribute (without the 'data-' prefix).
        value - Value of attribute
        Returns:
        Self reference