Annotation Interface Html


Annotation that can be applied to classes, fields, and methods to tweak how they are handled by HtmlSerializer.

Can be used in the following locations:

  • Marshalled classes/methods/fields.
  • @Rest-annotated classes and @RestOp-annotated methods when used with @HtmlApply.
See Also:
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Use the specified anchor text when serializing a URI.
    Optional description for the exposed API.
    Specifies what format to use for the HTML element.
    Adds a hyperlink to a bean property when rendered as HTML.
    boolean
    When true, don't add headers to tables.
    boolean
    When true, collections of beans should be rendered as trees instead of tables.
    Class<? extends HtmlRender>
    Associates an HtmlRender with a bean property for custom HTML rendering of the property.
    Specifies the CSS style to apply to the HTML element containing the bean property value.
  • Element Details

    • anchorText

      Use the specified anchor text when serializing a URI.

      The text can contain any bean property values resolved through variables of the form "{property-name}".

      Example:

      // Produces <a href='...'>drive</a> when serialized to HTML. @Html(anchorText="drive") @URI // Treat property as a URL public String getDrive() {...}

      This overrides the behavior specified by HtmlSerializer.Builder.uriAnchorText(AnchorText).

      Returns:
      The annotation value.
      Default:
      ""
    • description

      Optional description for the exposed API.
      Returns:
      The annotation value.
      Since:
      9.2.0
      Default:
      {}
    • format

      Specifies what format to use for the HTML element.
      Returns:
      The annotation value.
      Default:
      HTML
    • link

      Adds a hyperlink to a bean property when rendered as HTML.

      The text can contain any bean property values resolved through variables of the form "{property-name}".

      The URLs can be any of the following forms:

      • Absolute - e.g. "http://host:123/myContext/myServlet/myPath"
      • Context-root-relative - e.g. "/myContext/myServlet/myPath"
      • Context-relative - e.g. "context:/myServlet/myPath"
      • Servlet-relative - e.g. "servlet:/myPath"
      • Path-info-relative - e.g. "myPath"
      Example:

      public class FileSpace { @Html(link="servlet:/drive/{drive}") public String getDrive() { ...; } }

      Returns:
      The annotation value.
      Default:
      ""
    • noTableHeaders

      When true, don't add headers to tables.
      See Also:
      Returns:
      The annotation value.
      Default:
      false
    • noTables

      boolean noTables
      When true, collections of beans should be rendered as trees instead of tables.

      Default is false.

      Returns:
      The annotation value.
      Default:
      false
    • render

      Class<? extends HtmlRender> render
      Associates an HtmlRender with a bean property for custom HTML rendering of the property.

      This annotation applies to bean properties and classes.

      Returns:
      The annotation value.
      Default:
      org.apache.juneau.marshall.html.HtmlRender.class
    • style

      Specifies the CSS style to apply to the HTML element containing the bean property value.

      This is a simpler alternative to using render() when you only need to apply CSS styling without custom content transformation.

      Example:

      // Apply styling to a bean property @Html(style="white-space:normal;min-width:200px") public String getField() {...}

      If both style() and render() are specified, the render takes precedence.

      Returns:
      The annotation value.
      Default:
      ""