Simple template for adding tooltips to HTML5 bean constructs, typically in menu item widgets.
Tooltips depend on the existence of the tooltip
and tooltiptext
styles that should be
present in the stylesheet for the document.
The following examples shows how tooltips can be added to a menu item widget.
public class MyFormMenuItem extends MenuItemWidget {
@Override
public String getLabel(RestRequest req) throws Exception {
return "myform";
}
@Override
public Object getContent(RestRequest req) throws Exception {
return div(
form().id("form").action("servlet:/form").method(POST).children(
table(
tr(
th("Field 1:"),
td(input().name("field1").type("text")),
td(new Tooltip("(?)", "This is field #1!", br(), "(e.g. '", code("Foo"), "')"))
),
tr(
th("Field 2:"),
td(input().name("field2").type("text")),
td(new Tooltip("(?)", "This is field #2!", br(), "(e.g. '", code("Bar"), "')"))
)
)
)
);
}
}
See Also: