Class DataTablesResults<T>
- Type Parameters:
T- The row type.
Serializes (via the normal negotiated serializer) to the JSON shape DataTables expects from a server-side source:
{
draw— the draw counter echoed back from the request (cast to a number by DataTables).recordsTotal— total records before filtering.recordsFiltered— records after filtering (before paging).data— the page of rows.error— optional error message (omitted from the response whennull ).
Example:
- Since:
- 10.0.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> DataTablesResults<T>create()Static creator.static <T> DataTablesResults<T>Builds an error envelope: the draw counter echoed back, no rows, and no counts, with the caller's error message.getData()Returns the page of rows.intgetDraw()Returns the draw counter.getError()Returns the optional error message.longReturns the record count after filtering (before paging).longReturns the total record count before filtering.Sets the page of rows.setDraw(int value) Sets the draw counter.Sets the optional error message.setRecordsFiltered(long value) Sets the record count after filtering (before paging).setRecordsTotal(long value) Sets the total record count before filtering.
-
Constructor Details
-
DataTablesResults
public DataTablesResults()Constructor.
-
-
Method Details
-
create
Static creator.- Type Parameters:
T- The row type.- Returns:
- A new empty
DataTablesResults.
-
error
Builds an error envelope: the draw counter echoed back, no rows, and no counts, with the caller's error message.For an application-level failure an endpoint wants to report with HTTP 200 so DataTables surfaces
errorthrough itserrMode. Note thatDataTablesQueryno longer uses this for aBeanQuerySyntaxException(unknown column, too many search clauses, ...): since 2026-10-05 that propagates and is mapped centrally to HTTP 400 with anX-BeanQuery-Errorheader.Example:
return DataTablesResults.error (request .getDraw(),"Unknown column 'x'." );- Type Parameters:
T- The row type.- Parameters:
draw- The draw counter to echo back.message- The error message to show.- Returns:
- A new
DataTablesResultswith onlydrawanderrorset.
-
getDraw
Returns the draw counter.- Returns:
- The draw counter.
-
setDraw
Sets the draw counter.- Parameters:
value- The value.- Returns:
- This object.
-
getRecordsTotal
Returns the total record count before filtering.- Returns:
- The total record count.
-
setRecordsTotal
Sets the total record count before filtering.- Parameters:
value- The value.- Returns:
- This object.
-
getRecordsFiltered
Returns the record count after filtering (before paging).- Returns:
- The filtered record count.
-
setRecordsFiltered
Sets the record count after filtering (before paging).- Parameters:
value- The value.- Returns:
- This object.
-
getData
Returns the page of rows.- Returns:
- The page of rows. Can be
null .
-
setData
Sets the page of rows.- Parameters:
value- The value.- Returns:
- This object.
-
getError
Returns the optional error message.- Returns:
- The error message, or
null if none.
-
setError
Sets the optional error message.- Parameters:
value- The value.- Returns:
- This object.
-