Class ChoiceSection

java.lang.Object
org.apache.juneau.console.freemarker.Section
org.apache.juneau.console.freemarker.ChoiceSection

public final class ChoiceSection extends Section
A rail section of checkboxes over the distinct values of one dictionary column of a data source.

Publishes {schemaVersion:1, viewId, columns:{<dim>: [selected...]}, options:{deselected:[...]}}, omitting columns and options when every value is selected. The deselected list names the values the user has unticked (capped at max), so a reload can list them again and tick them back. The array value is a data-source extension: datatables do not apply it.

Unticking every value publishes an empty list (columns:{<dim>: []}). The data sources map an empty list to no restriction on the dimension, so "nothing ticked" shows every row, the same as "everything ticked". The section shows a "Select all" button while a filter is in force.

Example:

ChoiceSection.fromDim("orders", "reason").label("Reason").max(50) .publishes(Topics.filter("reasons"));

Since:
10.0.0
  • Method Details

    • fromDim

      public static ChoiceSection fromDim(String source, String dim)
      Creates a choice section.
      Parameters:
      source - The data source id (its topic is data:<source>).
      dim - The dictionary column whose values are listed.
      Returns:
      A new section.
    • max

      public ChoiceSection max(int value)
      Caps the values shown before "Show all".
      Parameters:
      value - The cap, at least 1. Defaults to 50.
      Returns:
      This object.
    • publishes

      public ChoiceSection publishes(String topic)
      Description copied from class: Section
      Sets the topic this section owns.
      Overrides:
      publishes in class Section
      Parameters:
      topic - A filter:<key> topic, normally Topics.filter(key). <key> becomes the section id.
      Returns:
      This object.
    • label

      public ChoiceSection label(String label)
      Description copied from class: Section
      Sets the section's legend text.
      Overrides:
      label in class Section
      Parameters:
      label - The label.
      Returns:
      This object.