Class DynIdAttribute

  • All Implemented Interfaces:
    j2html.tags.Renderable

    public class DynIdAttribute
    extends j2html.attributes.Attribute
    Dynamic id attribute that will get a number appended to its value in order to achieve uniqueness within a HTML document. To be used for generated SVG that may appear multiple times in the same document.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static DynIdAttribute dynId​(java.lang.String value)
      Creates a dynamic id attribute that can be passed to Tag.attr(Attribute).
      static java.lang.String ref​(java.lang.String value)
      Creates a reference (or a target anchor) for the given id (for example for the target of an xlink)
      static void resetDynIds()
      Removes all id counters.
      static java.lang.String url​(java.lang.String value)
      Creates an url() CSS function call using the reference for the given id as parameter (to be used for example in SVG presentation attributes)
      • Methods inherited from class j2html.attributes.Attribute

        getName, getValue, render, renderModel, setValue
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface j2html.tags.Renderable

        render, render, render, render
    • Method Detail

      • resetDynIds

        public static void resetDynIds()
        Removes all id counters. May be invoked before rendering a new HTML document.
      • dynId

        public static DynIdAttribute dynId​(java.lang.String value)
        Creates a dynamic id attribute that can be passed to Tag.attr(Attribute).
        Parameters:
        value - the (base) value
        Returns:
        the attribute (which renders to id="value<n>")
      • ref

        public static java.lang.String ref​(java.lang.String value)
        Creates a reference (or a target anchor) for the given id (for example for the target of an xlink)
        Parameters:
        value - the (base) value of the target id attribute
        Returns:
        the id reference: "#value<n>"
      • url

        public static java.lang.String url​(java.lang.String value)
        Creates an url() CSS function call using the reference for the given id as parameter (to be used for example in SVG presentation attributes)
        Parameters:
        value - the (base) value of the target id attribute
        Returns:
        the url() function: "url(#value<n>)"