Class Tbody<T extends Tbody<T>>


public class Tbody<T extends Tbody<T>> extends StyledElement<T>
Represents an HTML <tbody> element for grouping table body rows.

This class provides functionality to create and manage table body sections within HTML tables. The tbody element groups one or more <tr> elements containing the main data content of a table, distinct from header (<thead>) and footer (<tfoot>) sections. This semantic grouping improves table structure, accessibility, and enables independent styling and scrolling of table sections.

Features:

  • Groups table rows containing main body content
  • Provides semantic structure to HTML tables
  • Enables independent styling of table body rows
  • Supports scrollable body with fixed headers/footers
  • Can contain multiple row groups within a single table
  • Extends TableElement for table-specific functionality

Usage:


 // Create a table with structured sections
 Table table = new Table();

 // Add header section
 Thead thead = new Thead();
 Tr headerRow = new Tr();
 headerRow.addElement(new Th("Name"));
 headerRow.addElement(new Th("Age"));
 thead.addElement(headerRow);
 table.addElement(thead);

 // Add body section
 Tbody tbody = new Tbody();
 Tr row1 = new Tr();
 row1.addElement(new Td("John"));
 row1.addElement(new Td("30"));
 tbody.addElement(row1);

 Tr row2 = new Tr();
 row2.addElement(new Td("Jane"));
 row2.addElement(new Td("25"));
 tbody.addElement(row2);
 table.addElement(tbody);

 // Multiple tbody elements for grouping
 Tbody group1 = new Tbody();
 // ... add rows
 Tbody group2 = new Tbody();
 // ... add rows
 table.addElement(group1);
 table.addElement(group2);
 
Since:
2007
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Constructor Details

    • Tbody

      public Tbody()
      Constructs a Tbody element.

      Creates a new <tbody> element that can contain table rows representing the main body content of an HTML table.

  • Method Details

    • addRow

      public Tr addRow()
      Creates and adds a new row to this table section.
      Returns:
      The newly created Tr element.
    • addRow

      public void addRow(Tr row)
      Adds an existing row to this table section.
      Parameters:
      row - The Tr element to add.
    • getRow

      public Tr getRow(int index)
      Returns the row at the specified index.
      Parameters:
      index - The zero-based index of the row to retrieve.
      Returns:
      The Tr element at the specified index, or null if the index is out of bounds.
    • getRows

      public TableRows getRows()
      Returns all rows contained in this table section.
      Returns:
      A TableRows collection containing all Tr elements in this section.
    • removeAllRows

      public void removeAllRows()
      Removes all rows from this table section.
    • removeRow

      public void removeRow(int index)
      Removes the row at the specified index.
      Parameters:
      index - The zero-based index of the row to remove.
    • removeRows

      public void removeRows(int start, int end)
      Removes rows in the specified range (inclusive).
      Parameters:
      start - The zero-based index of the first row to remove.
      end - The zero-based index of the last row to remove.
    • registerAddition

      public final void registerAddition()
      Registers an addition to this element by notifying the parent.

      Table sections delegate update registration to their parent table element to ensure proper synchronization of table structure changes.

      Overrides:
      registerAddition in class Element<T extends com.oorian.html.elements.TableElement<T>>
    • registerSubtraction

      public final void registerSubtraction()
      Registers a subtraction from this element by notifying the parent.

      Table sections delegate update registration to their parent table element to ensure proper synchronization of table structure changes.

      Overrides:
      registerSubtraction in class Element<T extends com.oorian.html.elements.TableElement<T>>
    • registerUpdate

      public final void registerUpdate()
      Registers an update to this element by notifying the parent.

      Table sections delegate update registration to their parent table element to ensure proper synchronization of table structure changes.

      Overrides:
      registerUpdate in class Element<T extends com.oorian.html.elements.TableElement<T>>