Class Data


@Marshalled(typeName="data") public class Data extends HtmlElementMixed<Data>
DTO for an HTML <data> element.

The data element represents its contents, along with a machine-readable form of those contents in the value attribute. It is used to provide both human-readable and machine-readable versions of the same data, making it easier for scripts and other automated systems to process the information while still displaying meaningful content to users. The value attribute should contain the machine-readable version of the data.

Examples:

import static org.apache.juneau.bean.html5.HtmlBuilder.*; // Simple data element Data simple = data("12345", "Product #12345"); // Data with styling Data styled = data("USD", "US Dollar") .class_("currency"); // Data in a sentence P sentence = p( "Price: ", data("29.99", "$29.99"), " per item" ); // Data with complex content Data complex = data("2024-01-15", "January 15, 2024", span().class_("date").children(" (Monday)") ); // Data with multiple attributes Data multiple = data("SKU-12345", "SKU: 12345") .class_("product-sku") .title("Product SKU"); // Data with ID Data withId = data("user-123", "User ID: 123") .id("user-id") .children("User ID: 123"); // Data with styling Data styled2 = data("active", "Active") .style("color: green; font-weight: bold;");

The following convenience methods are provided for constructing instances of this bean:

See Also:
  • Constructor Details

    • Data

      public Data()
      Creates an empty Data element.
    • Data

      public Data(String value, Object child)
      Creates a Data element with the specified value(Object) attribute and child node.
      Parameters:
      value - The value(Object) attribute. Can be null to unset the attribute.
      child - The child node. Can be null (a null entry is added to the children list).
  • Method Details

    • value

      public Data value(Object value)
      value attribute.

      Machine-readable value.

      Parameters:
      value - The new value for this attribute. Typically a Number or String. Can be null to unset the attribute.
      Returns:
      This object.