## org.mortbay.html
Class Table

    java.lang.Object
      |
      +--org.mortbay.html.Element
            |
            +--org.mortbay.html.Composite
                  |
                  +--org.mortbay.html.Block
                        |
                        +--org.mortbay.html.Table

public class Table
extends Block

A HTML Table element.

The Table Element works by calling newRow and then adding cells or headings.

Notes
Tables are implemented by nesting a cell Block within a row Block within the table which is also a Block (see nest() on class Composite). Once a row and cell have been created, calling add or attributes on the table actually calls the cell.

See Also:
  `Element`

Field Summary

Fields inherited from class org.mortbay.html.Block
`Bold, Center, Div, Italic, Left, Listing, Plain, Pre, Quote, Right, Span, Xmp`

Fields inherited from class org.mortbay.html.Element
`ALIGN, BGCOLOR, BOTTOM, CENTER, CLASS, COLOR, HEIGHT, ID, LEFT, MIDDLE, noAttributes, RIGHT, SIZE, STYLE, TOP, VALIGN, WIDTH`

Constructor Summary
`Table()` Construct Table.
`Table(int border)` Construct Table.
`Table(int border, java.lang.String attributes)` Construct Table with attributes.

Method Summary
`Table` `addCell(java.lang.Object o)`
`Table` `addCell(java.lang.Object o, java.lang.String attributes)`
`Table` `addHeading(java.lang.Object o)`
`Table` `addHeading(java.lang.Object o, java.lang.String attributes)`
`Block` `cell()` Get the current cell Block element.
`Table` `cellPadding(int padding)` Set the table cell padding.
`Table` `cellSpacing(int s)` Set the table cell spacing.
`Block` `defaultCell()` Access the default cell template.
`Block` `defaultHead()` Access the default header cell template.
`Block` `defaultRow()` Access the default row template.
`Table` `newCell()`
`Table` `newCell(java.lang.String attributes)`
`Table` `newHeading()`
`Table` `newRow()` Create new table row.
`Table` `newRow(java.lang.String attributes)` Create new table row with attributes.
`Block` `row()` Get the current row Block element.
`static void` `setCellNestingFactory(CompositeFactory factory)` Deprecated. Use setNestingFactory or setThreadNestingFactory
`void` `setNestingFactory(CompositeFactory factory)` Add cell nesting factory for table.
`static void` `setThreadNestingFactory(CompositeFactory factory)` Add cell nesting factory for thread.
`Table` `spacing(int h, int v)` Set horizontal and vertical spacing.

Methods inherited from class org.mortbay.html.Block
`write`

Methods inherited from class org.mortbay.html.Composite
`add, contents, nest, replace, reset, setNest, size, unnest`

Methods inherited from class org.mortbay.html.Element
`attribute, attribute, attribute, attributes, attributes, bgColor, bottom, center, color, cssClass, cssID, height, height, height, left, middle, right, setAttributesFrom, size, size, style, top, toString, width, width, width, write, write`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### Table

    public Table()

  Construct Table.

### Table

    public Table(int border)

  Construct Table.

### Table

    public Table(int border,
                 java.lang.String attributes)

  Construct Table with attributes.

Method Detail

### newRow

    public Table newRow()

  Create new table row. Attributes set after this call and before a call to newCell or newHeader are considered row attributes.

### newRow

    public Table newRow(java.lang.String attributes)

  Create new table row with attributes. Attributes set after this call and before a call to newCell or newHeader are considered row attributes.

### newCell

    public Table newCell()

### newCell

    public Table newCell(java.lang.String attributes)

### addCell

    public Table addCell(java.lang.Object o)

### addCell

    public Table addCell(java.lang.Object o,
                         java.lang.String attributes)

### newHeading

    public Table newHeading()

### addHeading

    public Table addHeading(java.lang.Object o)

### addHeading

    public Table addHeading(java.lang.Object o,
                            java.lang.String attributes)

### cellSpacing

    public Table cellSpacing(int s)

  Set the table cell spacing.

  Parameters:
    `s` - spacing in pixels
  Returns:
    This table for call chaining

### cellPadding

    public Table cellPadding(int padding)

  Set the table cell padding.

  Parameters:
    `padding` - the cell padding in pixels
  Returns:
    This table for call chaining

### spacing

    public Table spacing(int h,
                         int v)

  Set horizontal and vertical spacing.

  Parameters:
    `h` - horizontal spacing
    `v` - vertical spacing
  Returns:
    This table for call chaining

### row

    public Block row()

  Get the current row Block element. Use this call for setting row attributes.

  Returns:
    The Block instance which has been nested in the table as the row

### cell

    public Block cell()

  Get the current cell Block element. Use this call for setting cell attributes.

  Returns:
    The Block instance which has been nested in the row as the cell

### setCellNestingFactory

    public static void setCellNestingFactory(CompositeFactory factory)

  Deprecated. Use setNestingFactory or setThreadNestingFactory

  Add cell nesting factory. Set the CompositeFactory for this thread. Each new cell in the table added by this thread will have a new Composite from this factory nested in the Cell.

  Parameters:
    `factory` - The factory for this Thread. If null clear this threads factory.

### setThreadNestingFactory

    public static void setThreadNestingFactory(CompositeFactory factory)

  Add cell nesting factory for thread. Set the CompositeFactory for this thread. Each new cell in the table added by this thread will have a new Composite from this factory nested in the Cell.

  Parameters:
    `factory` - The factory for this Thread. If null clear this threads factory.

### setNestingFactory

    public void setNestingFactory(CompositeFactory factory)

  Add cell nesting factory for table. Set the CompositeFactory for this thread. Each new cell in the table added by this thread will have a new Composite from this factory nested in the Cell.

  Parameters:
    `factory` - The factory for this Thread. If null clear this threads factory.

### defaultRow

    public Block defaultRow()

  Access the default row template. The Block returned is used as a template for all new rows added to the table. Thus if attributes or content are added to the default row, the these are added to each new row in the table.

  Returns:
    The default row template

### defaultHead

    public Block defaultHead()

  Access the default header cell template. The Block returned is used as a template for all new header cells added to the table. Thus if attributes or content are added to the default cell, the these are added to each new cell in the table.

  Returns:
    The default head cell template

### defaultCell

    public Block defaultCell()

  Access the default cell template. The Block returned is used as a template for all new cells added to the table. Thus if attributes or content are added to the default cell, the these are added to each new cell in the table.

  Returns:
    The default cell template

Copyright © 2000 Mortbay Consulting Pty. Ltd. All Rights Reserved.