Class DataTablesRequest

java.lang.Object
org.apache.juneau.console.datatables.DataTablesRequest

public class DataTablesRequest extends Object
The DataTables server-side-processing request envelope — the JSON input bean paired with the DataTablesResults JSON output bean.

This bean is a faithful model of the DataTables server-side request; it carries no query-engine types and knows nothing about BeanQuery. The adapter in org.apache.juneau.console.datatables.adapter maps a parsed instance onto a BeanQuery.

Shape (fields omitted from the request keep their defaults):

{ draw: 1, start: 0, length: 10, search: { value: "", regex: false, fixed: [] }, columns: [ { data: "name", name: "", searchable: true, orderable: true, search: { value: "", regex: false, fixed: [] } } ], order: [ { column: 0, dir: "asc", name: "" } ] }

Every property DataTables 2.x core sends is modelled (including search.fixed and order[].name, both new in 2.x), so the request parses under Juneau's default strict bean parsing, which rejects unknown properties. Any OTHER top-level property - one an application merges in through JuneauDataTables.ajax(url, {data:{...}}), or one a DataTables extension adds (SearchBuilder's searchBuilder, SearchPanes' searchPanes) - is collected into getExtra() instead of failing the parse. The adapter ignores it.

Example:

@RestPost("/releases/query") public DataTablesResults<Release> queryReleases(@Content DataTablesRequest request) { try (var session = CONTEXT.getSession(releases)) { return DataTablesQuery.run(request, session); } }

Since:
10.0.0
  • Constructor Details

  • Method Details

    • getDraw

      public int getDraw()
      Returns the draw counter echoed back on the response.
      Returns:
      The draw counter.
    • setDraw

      public DataTablesRequest setDraw(int value)
      Sets the draw counter.
      Parameters:
      value - The value.
      Returns:
      This object.
    • getStart

      public int getStart()
      Returns the 0-based index of the first record to return.
      Returns:
      The paging start index.
    • setStart

      public DataTablesRequest setStart(int value)
      Sets the 0-based index of the first record to return.
      Parameters:
      value - The value.
      Returns:
      This object.
    • getLength

      public int getLength()
      Returns the number of records the page should return (-1 means all records, no paging).
      Returns:
      The page length.
    • setLength

      public DataTablesRequest setLength(int value)
      Sets the number of records the page should return (-1 means all records, no paging).
      Parameters:
      value - The value.
      Returns:
      This object.
    • getSearch

      Returns the global search descriptor.
      Returns:
      The global search, or null if none.
    • setSearch

      Sets the global search descriptor.
      Parameters:
      value - The value.
      Returns:
      This object.
    • getColumns

      Returns the column descriptors.
      Returns:
      The columns, or null if none.
    • setColumns

      Sets the column descriptors.
      Parameters:
      value - The value.
      Returns:
      This object.
    • getOrder

      Returns the ordering descriptors.
      Returns:
      The order entries, or null if none.
    • setOrder

      Sets the ordering descriptors.
      Parameters:
      value - The value.
      Returns:
      This object.
    • getExtra

      Returns every top-level request property that is not one of the modelled DataTables properties.

      For example the tenant in JuneauDataTables.ajax(url, {data:{tenant:'x'}}), or an extension's own request key. Lets a handler read application parameters that ride the JSON body.

      Returns:
      The extra properties, keyed by name. Never null.
    • setExtra

      @BeanProp(name="*") public void setExtra(String name, Object value)
      Records a top-level request property that is not one of the modelled DataTables properties.
      Parameters:
      name - The property name.
      value - The property value.