Class Table

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.HtmlComponent
org.vaadin.firitin.fields.internalhtmltable.Table
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle, Serializable, TableRowContainer

@Tag("table") public class Table extends com.vaadin.flow.component.HtmlComponent implements TableRowContainer
Represents the html table element (<table>). Can contain
  • a caption
  • a column group
  • a thead
  • a tfoot
  • a tbody or a set of table rows


Sub elements except for rows are created when calling the respective getter, for instance getHead(). Since <table> expects a certain order of elements, this class takes care of positioning them in the correct order (e.g. head <thead>, then <tbody> and then <tfoot>, etc).

Also a table must not contain rows as direct children, when having a <tbody>. Therefore, all previously to the table assigned rows are automatically assigned to the <tbody>, when getBody() is called.

Also all subsequent calls to any table row method are automatically delegated to the <tbody>.
Author:
Stefan Uebe
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Adds a single row instance to this container.
    addRows(int rows)
    Adds multiple rows to this instance based on the given integer (must be greater than 0).
    void
    addRows(TableRow... rows)
    Adds the given list of rows.
    Returns the TableBody for this instance.
    Returns the TableCaption for this instance.
    Returns the TableColumnGroup for this instance.
    Returns the TableFoot for this instance.
    Returns the TableHead for this instance.
    insertRow(int index)
    Inserts a single row instance at the given index to this container.
    void
    insertRows(int index, TableRow... rows)
    Inserts the given rows at the given index to this instance.
    void
    Removes all rows.
    void
    Removes the body instance from this table.
    void
    Removes the caption instance from this table.
    void
    Removes the column group instance from this table.
    void
    Removes the foot instance from this table.
    void
    Removes the head instance from this table.
    void
    removeRow(int index)
    Removes the row with the given index.
    void
    Removes the given rows from this instance.
    void
    replaceRow(int index, TableRow row)
    Replaces a single row instance to the given index in this container and replaces the existing row.
    void
    setRow(int index, TableRow row)
    Replaces a single row instance to the given index in this container and replaces the existing row.
    Returns the rows of this instance as a stream.

    Methods inherited from class com.vaadin.flow.component.HtmlComponent

    getTitle, setTitle

    Methods inherited from class com.vaadin.flow.component.Component

    addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisible

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.vaadin.flow.component.AttachNotifier

    addAttachListener

    Methods inherited from interface com.vaadin.flow.component.DetachNotifier

    addDetachListener

    Methods inherited from interface com.vaadin.flow.component.HasElement

    getElement

    Methods inherited from interface com.vaadin.flow.component.HasSize

    getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull

    Methods inherited from interface com.vaadin.flow.component.HasStyle

    addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName

    Methods inherited from interface org.vaadin.firitin.fields.internalhtmltable.TableRowContainer

    getChildren, getRow, getRows
  • Constructor Details

    • Table

      public Table()
  • Method Details

    • getCaption

      public TableCaption getCaption()
      Returns the TableCaption for this instance. Creates a new instance on the first call.
      Returns:
      caption
    • getColumnGroup

      public TableColumnGroup getColumnGroup()
      Returns the TableColumnGroup for this instance. Creates a new instance on the first call.
      Returns:
      column group
    • getHead

      public TableHead getHead()
      Returns the TableHead for this instance. Creates a new instance on the first call.
      Returns:
      table head
    • removeHead

      public void removeHead()
      Removes the head instance from this table.

      Does not move any rows from the head to the table itself. That has to be done manually.
    • removeFoot

      public void removeFoot()
      Removes the foot instance from this table.

      Does not move any rows from the foot to the table itself. That has to be done manually.
    • removeBody

      public void removeBody()
      Removes the body instance from this table.

      Does not move any rows from the body to the table itself. That has to be done manually.
    • removeCaption

      public void removeCaption()
      Removes the caption instance from this table.
    • removeColumnGroup

      public void removeColumnGroup()
      Removes the column group instance from this table.
    • getBody

      public TableBody getBody()
      Returns the TableBody for this instance. Creates a new instance on the first call.

      When rows have been assigned to this table instance before calling this method, these rows will be reassigned to the body to prevent creating an invalid dom structure.

      Any subsequent calls to this table's addRows(TableRow...) method will be delegated to the body's one.
      Returns:
      table body
    • getFoot

      public TableFoot getFoot()
      Returns the TableFoot for this instance. Creates a new instance on the first call.
      Returns:
      foot
    • addRows

      public void addRows(TableRow... rows)
      Adds the given list of rows.

      When this table has a body, it will automatically delegate the call to the body's respective method.
      Specified by:
      addRows in interface TableRowContainer
      Parameters:
      rows - rows
    • insertRows

      public void insertRows(int index, TableRow... rows)
      Inserts the given rows at the given index to this instance. Existing items will be placed after the inserted items.

      When this table has a body, it will automatically delegate the call to the body's respective method.
      Specified by:
      insertRows in interface TableRowContainer
      Parameters:
      index - to insert the rows at
      rows - rows
    • replaceRow

      public void replaceRow(int index, TableRow row)
      Replaces a single row instance to the given index in this container and replaces the existing row.

      When this table has a body, it will automatically delegate the call to the body's respective method.
      Specified by:
      replaceRow in interface TableRowContainer
      Parameters:
      index - index to set the new item to
      row - row
    • removeRows

      public void removeRows(TableRow... rows)
      Removes the given rows from this instance. Items, that are not child of this instance, will lead to an exception.

      When this table has a body, it will automatically delegate the call to the body's respective method.
      Specified by:
      removeRows in interface TableRowContainer
      Parameters:
      rows - rows to remove
    • streamRows

      public Stream<TableRow> streamRows()
      Returns the rows of this instance as a stream. Empty if no rows have been added yet.

      When this table has a body, it will automatically delegate the call to the body's respective method.
      Specified by:
      streamRows in interface TableRowContainer
      Returns:
      rows as stream
    • addRow

      public TableRow addRow()
      Adds a single row instance to this container. The created row is returned for further configuration.

      When this table has a body, it will automatically delegate the call to the body's respective method.
      Specified by:
      addRow in interface TableRowContainer
      Returns:
      the created row
    • addRows

      public TableRow[] addRows(int rows)
      Adds multiple rows to this instance based on the given integer (must be greater than 0). The created rows are returned as an array, that can be used for further configuration.

      When this table has a body, it will automatically delegate the call to the body's respective method.
      Specified by:
      addRows in interface TableRowContainer
      Parameters:
      rows - amount of rows to add
      Returns:
      created row objects
    • insertRow

      public TableRow insertRow(int index)
      Inserts a single row instance at the given index to this container. Existing items will be placed after the inserted items. The created row is returned for further configuration.

      When this table has a body, it will automatically delegate the call to the body's respective method.
      Specified by:
      insertRow in interface TableRowContainer
      Parameters:
      index - to insert the row at
      Returns:
      the created row
    • setRow

      public void setRow(int index, TableRow row)
      Replaces a single row instance to the given index in this container and replaces the existing row.

      This method has the same functionality as replaceRow(int, TableRow).

      When this table has a body, it will automatically delegate the call to the body's respective method.
      Specified by:
      setRow in interface TableRowContainer
      Parameters:
      index - index to set the new item to
      row - row
      See Also:
    • removeAllRows

      public void removeAllRows()
      Removes all rows.

      When this table has a body, it will automatically delegate the call to the body's respective method.
      Specified by:
      removeAllRows in interface TableRowContainer
    • removeRow

      public void removeRow(int index)
      Removes the row with the given index. Noop, if no row has been found for that index.

      When this table has a body, it will automatically delegate the call to the body's respective method.
      Specified by:
      removeRow in interface TableRowContainer
      Parameters:
      index - index to remove