Class DataTablesTable
Table DOM bean from a collection of rows — a server-rendered "plain
table" that the browser upgrades in place with $('#id').DataTable().
The generated table carries:
- a stable
idattribute (the selector the browser initializer targets), - a
data-juneau-datatablemarker attribute (the hook the shippedjuneau-datatables.jsglue auto-initializes — seeDataTablesMixin), - a
<thead>of column titles (fromDataTablesColumns), and - a
<tbody>of one<tr>per row, with cells pulled positionally from the columndatakeys.
Because it returns a Juneau Table DOM bean (not a raw HTML string), the markup is produced by the normal
HtmlSerializer with its usual escaping — there's no bespoke string concatenation to get wrong. This
helper is intentionally scoped to the juneau-console-datatables module so the marshall core and
HtmlDocSerializer stay decoupled from any DataTables-specific rendering.
Example:
See Also:
- Since:
- 10.0.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringMarker attribute carrying a server endpoint URL that the shippedjuneau-datatables.jsglue auto-wires intoopts.ajaxviaJuneauDataTables.ajax(url)(withopts.serverSidedefaulted totrue ) when the parsedMARKER_ATTRoptions have noajaxkey.static final StringMarker attribute the shippedjuneau-datatables.jsglue looks for to auto-initialize a table. -
Method Summary
Modifier and TypeMethodDescriptionstatic Tableof(String id, Collection<?> rows, Class<?> rowType) Builds a DataTables-ready table, deriving the columns from the specified row bean type viaDataTablesColumns.of(Class).static TableBuilds a DataTables-ready table from an explicit column list (e.g. one produced byDataTablesColumnsand then adjusted).static Tableof(MarshallingContext ctx, String id, Collection<?> rows, Class<?> rowType) Builds a DataTables-ready table using the specified marshalling context, deriving the columns from the specified row bean type viaDataTablesColumns.of(MarshallingContext, Class), additively honoring each bean property's@Html(render)the same way the ordinaryHtmlSerializer/HtmlDocSerializerpath already does.static Tableof(MarshallingContext ctx, String id, Collection<?> rows, List<Map<String, Object>> columns) Builds a DataTables-ready table from an explicit column list using the specified marshalling context for bean-property cell reads.
-
Field Details
-
MARKER_ATTR
Marker attribute the shippedjuneau-datatables.jsglue looks for to auto-initialize a table.- See Also:
-
AJAX_ATTR
Marker attribute carrying a server endpoint URL that the shippedjuneau-datatables.jsglue auto-wires intoopts.ajaxviaJuneauDataTables.ajax(url)(withopts.serverSidedefaulted totrue ) when the parsedMARKER_ATTRoptions have noajaxkey.- See Also:
-
-
Method Details
-
of
Builds a DataTables-ready table, deriving the columns from the specified row bean type viaDataTablesColumns.of(Class).- Parameters:
id- The table's DOMid(the$('#id')selector). Must not benull .rows- The rows to render (beans or maps). Must not benull ; may be empty.rowType- The row bean type used to derive the columns. Must not benull and must be a bean.- Returns:
- A new
TableDOM bean.
-
of
Builds a DataTables-ready table using the specified marshalling context, deriving the columns from the specified row bean type viaDataTablesColumns.of(MarshallingContext, Class), additively honoring each bean property's@Html(render)the same way the ordinaryHtmlSerializer/HtmlDocSerializerpath already does.Using one context for both column derivation and cell reads keeps the
datakeys and the row values consistent when a resource applies custom bean settings.Behavior note (not purely additive): a bean already carrying
@Html(render=...)for the existing HtmlDoc/serializer path now ALSO renders through that same render when passed through this overload — this overload no longer delegates to the raw-valueof(MarshallingContext, String, Collection, List)columns-overload path the way it used to.@Html(render)honoring applies to bean rows only. AMap-based row (beanrowTypefor columns,Maprows for values — supported today viavalue()'srow instanceof Mapbranch) has noBeanPropertyMetato resolve a render from, so it keeps rendering the raw value, exactly as before.- Parameters:
ctx- The marshalling context supplying bean metadata (property naming/ordering) and cell reads. Must not benull .id- The table's DOMid(the$('#id')selector). Must not benull .rows- The rows to render (beans or maps). Must not benull ; may be empty.rowType- The row bean type used to derive the columns. Must not benull and must be a bean.- Returns:
- A new
TableDOM bean.
-
of
Builds a DataTables-ready table from an explicit column list (e.g. one produced byDataTablesColumnsand then adjusted).- Parameters:
id- The table's DOMid(the$('#id')selector). Must not benull .rows- The rows to render (beans or maps). Must not benull ; may be empty.columns- The column descriptors (each carrying at leastdataandtitle). Must not benull .- Returns:
- A new
TableDOM bean.
-
of
public static Table of(MarshallingContext ctx, String id, Collection<?> rows, List<Map<String, Object>> columns) Builds a DataTables-ready table from an explicit column list using the specified marshalling context for bean-property cell reads.- Parameters:
ctx- The marshalling context used to read bean-property cell values. Must not benull .id- The table's DOMid(the$('#id')selector). Must not benull .rows- The rows to render (beans or maps). Must not benull ; may be empty.columns- The column descriptors (each carrying at leastdataandtitle). Must not benull .- Returns:
- A new
TableDOM bean.
-