Skip to main content

@Html Annotation

The @Html annotation can be used to customize how POJOs are serialized to HTML on a per-class/field/method basis.

HtmlanchorText format link noTableHeaders noTables render

The @Html(link) annotation adds a hyperlink to a bean property when rendered as HTML.

Example
public class FileSpace {
// Add a hyperlink to this bean property.
@Html(link="servlet:/drive/{drive}")
public String getDrive() {...}
}

The @Html(anchorText) annotation is used to specify the anchor text of a hyperlink.

Example
// Produces CLICK ME! when serialized to HTML.
public class FileSpace {
// Add a hyperlink to this bean property.
@Html(link="servlet:/drive/{drive}", anchorText="CLICK ME!")
public String getDrive() {...}
}

The @Html(format) annotation is used to specify what format to use for HTML elements. For example, the HTML beans defined in the html5 package use format=XML so that the beans get serialized as standard XML:

Example
// Parent class of all HTML DTO bean classes.
@Html(format=XML)
public abstract class HtmlElement {...}

The @Html(noTableHeaders) annotation is used to prevent beans from being serialized with table headers.

The @Html(noTables) annotation is used to force beans to be serialized as trees instead of tables