java.lang.Object
org.jdrupes.mdoclet.internal.doclets.toolkit.Content
org.jdrupes.mdoclet.internal.doclets.formats.html.Table<T>
Typparameter:
T - the class or interface used to distinguish the rows to be displayed for each tab, or Void when a table does not contain tabs

public class Table<T> extends Content
An HTML container used to display summary tables for various kinds of elements and other tabular data.

This class historically used to generate an HTML

element but has been updated to render its content as a stream of
elements that rely on CSS Grid Layout for styling. This provides for more flexible layout options, such as splitting up table rows on small displays.

The table should be used in three phases:

  1. Configuration: the overall characteristics of the table should be specified
  2. Population: the content for the cells in each row should be added
  3. Generation: the HTML content and any associated JavaScript can be accessed

Many methods return the current object, to facilitate fluent builder-style usage.

A table may support filtered views, which can be selected by clicking on one of a list of tabs above the table. If the table does not support filtered views, the caption element is typically displayed as a single (inactive) tab. The filtered views use a Predicate to identify the rows to be shown for each tab. The type parameter for the predicate is the type parameter T for the table. The type parameter should be Void when the table is not configured to use tabs.

  • Konstruktordetails

    • Table

      public Table(HtmlStyle tableStyle)
      Creates a builder for an HTML element representing a table.
      Parameter:
      tableStyle - the style class for the top-level
      element
  • Methodendetails

    • setCaption

      public Table<T> setCaption(Content captionContent)
      Sets the caption for the table.

      This is ignored if the table is configured to provide tabs to select different subsets of rows within the table.

      Parameter:
      captionContent - the caption
      Gibt zurück:
      this object
    • addTab

      public Table<T> addTab(Content label, Predicate<T> predicate)
      Adds a tab to the table.

      Tabs provide a way to display subsets of rows, as determined by a predicate for the tab, and an item associated with each row. Tabs will appear left-to-right in the order they are added.

      Parameter:
      label - the tab label
      predicate - the predicate
      Gibt zurück:
      this object
    • setDefaultTab

      public Table<T> setDefaultTab(Content label)
      Sets the label for the default tab, which displays all the rows in the table.

      This tab will appear first in the left-to-right list of displayed tabs.

      Parameter:
      label - the default tab label
      Gibt zurück:
      this object
    • setAlwaysShowDefaultTab

      public Table<T> setAlwaysShowDefaultTab(boolean showDefaultTab)
      Sets whether to display the default tab even if tabs are empty or only contain a single tab.
      Parameter:
      showDefaultTab - true if default tab should always be shown
      Gibt zurück:
      this object
    • setRenderTabs

      public Table<T> setRenderTabs(boolean renderTabs)
      Allows to set whether tabs should be rendered for this table.

      Some pages use their own controls to select table categories, in which case the tabs are omitted.

      Parameter:
      renderTabs - true if table tabs should be rendered
      Gibt zurück:
      this object
    • setHeader

      public Table<T> setHeader(TableHeader header)
      Sets the header for the table.

      Notes:

      • The column styles are not currently applied to the header, but probably should, eventually
      Parameter:
      header - the header
      Gibt zurück:
      this object
    • setColumnStyles

      public Table<T> setColumnStyles(HtmlStyle... styles)
      Sets the styles for be used for the cells in each row.

      Note:

      • The column styles are not currently applied to the header, but probably should, eventually
      Parameter:
      styles - the styles
      Gibt zurück:
      this object
    • setColumnStyles

      public Table<T> setColumnStyles(List<HtmlStyle> styles)
      Sets the styles for be used for the cells in each row.

      Note:

      • The column styles are not currently applied to the header, but probably should, eventually
      Parameter:
      styles - the styles
      Gibt zurück:
      this object
    • setGridStyle

      public Table<T> setGridStyle(HtmlStyle gridStyle)
      Sets the style for the table’s grid which controls allocation of space among table columns.

      The style should contain a display: grid; property and its number of columns must match the number of column styles and content passed to other methods in this class.

      Parameter:
      gridStyle - the grid style
      Gibt zurück:
      this object
    • setId

      public Table<T> setId(HtmlId id)
      Sets the id attribute of the table.

      This is required if the table has tabs, in which case a subsidiary id will be generated for the tabpanel. This subsidiary id is required for the ARIA support.

      Parameter:
      id - the id
      Gibt zurück:
      this object
    • addRow

      public void addRow(Content... contents)
      Adds a row of data to the table.

      Each item of content should be suitable for use as the content of a

or cell. This method should not be used when the table has tabs: use a method that takes an Element parameter instead.
Parameter:
contents - the contents for the row
  • addRow

    public void addRow(List<Content> contents)
    Adds a row of data to the table.

    Each item of content should be suitable for use as the content of a

  • or cell. This method should not be used when the table has tabs: use a method that takes an item parameter instead.
    Parameter:
    contents - the contents for the row
  • addRow

    public void addRow(T item, Content... contents)
    Adds a row of data to the table.

    Each item of content should be suitable for use as the content of a

  • or cell.

    If tabs have been added to the table, the specified item will be used to determine whether the row should be displayed when any particular tab is selected, using the predicate specified when the tab was added.

    Parameter:
    item - the item
    contents - the contents for the row
    Löst aus:
    NullPointerException - if tabs have previously been added to the table and item is null
  • addRow

    public void addRow(T item, List<Content> contents)
    Adds a row of data to the table.

    Each item of content should be suitable for use as the content of a

    cell.

    If tabs have been added to the table, the specified item will be used to determine whether the row should be displayed when any particular tab is selected, using the predicate specified when the tab was added.

    Parameter:
    item - the item
    contents - the contents for the row
    Löst aus:
    NullPointerException - if tabs have previously been added to the table and item is null
  • isEmpty

    public boolean isEmpty()
    Returns whether the table is empty.

    The table is empty if it has no (body) rows.

    Angegeben von:
    isEmpty in Klasse Content
    Gibt zurück:
    true if the table has no rows
  • write

    public boolean write(Writer out, String newline, boolean atNewline) throws IOException
    Beschreibung aus Klasse kopiert: Content
    Writes content to a writer, using a given newline sequence, which should be either \n or the platform line separator.
    Angegeben von:
    write in Klasse Content
    Parameter:
    out - the writer
    newline - the newline sequence to use
    atNewline - whether the writer has just written a newline
    Gibt zurück:
    whether the writer has just written a newline
    Löst aus:
    IOException - if an error occurs while writing the output