Common Attributes

UI components often share certain intentions. This topic is describing the current intentions available, such that the benefit of standardization can be leveraged. When developing a new server component, it is RECOMMENDED to use these shared intentions, instead of creating your own names. Any common intention arises in the future will be also added here.

This concept is analogous to HTML global attributes.

Currently the following properties and nodes are common:

granite:commonAttrs
granite:idstring

The HTML id attribute.

granite:relstring

The HTML class attribute. This is used to indicate the semantic relationship of the component similar to HTML rel attribute.

granite:classstring

The HTML class attribute.

granite:titlestring
i18n

The HTML title attribute.

granite:hiddenboolean

The HTML hidden attribute.

granite:itemscopeboolean

The HTML itemscope attribute.

granite:itemtypestring

The HTML itemtype attribute.

granite:itempropstring

The HTML itemprop attribute.

granite:data

Each property of this node is converted into a HTML data-* attribute. If the property value is an instance of a String, it will be interpreted as StringEL. The property with a prefixed name is ignored.

Component Development

To leverage these common attributes in your component, you can use ComponentHelper#populateCommonAttrs(AttrBuilder):

Tag tag = cmp.consumeTag();
AttrBuilder attrs = tag.getAttrs();
cmp.populateCommonAttrs(attrs);