Skip to main content

Using with HTML Beans

The HtmlBeansResource class shows how HTML5 beans can be used to generate arbitrary HTML on REST endpoints.

table

The aTable() method shows an example of rendering an HTML table.

@RestGet
public Table aTable() {
return table(
tr(
th("c1"), th("c2")
),
tr(
td("v1"), td("v2")
)
);
}
HTML representation

HTML Table

JSON representation

HTML Table JSON

div

The aDiv() method shows an example of rendering a div tag with mixed content.

@RestGet
@HtmlDocConfig(
aside={
"",
" Example of serialized org.apache.juneau.bean.html5.Div bean.",
""
}
)
public HtmlElement aDiv() {
return div()
.children(
p("Juneau supports ", b(i("mixed")), " content!")
)
.onmouseover("alert(\"boo!\");");
}
HTML representation

HTML Div

JSON representation

HTML Div JSON

form

The aForm() method shows an example of rendering an HTML form.

@RestGet
@HtmlDocConfig(
aside={
"",
" Example of serialized org.apache.juneau.bean.html5.Form bean.",
""
}
)
public Form aForm() {
return form().action("/submit").method("POST")
.children(
"Position (1-10000): ", input("number").name("pos").value(1), br(),
"Limit (1-10000): ", input("number").name("limit").value(100), br(),
button("submit", "Submit"), button("reset", "Reset")
);
}
HTML representation

HTML Form

JSON representation

HTML Form JSON