Renders an OLAP Table.

Table Component and Extensions

The TableComponent is extended thru TableComponentExtensions. The plain table component w/o extensions paints the table w/o any navigations. The extensions add UI elements like expand / collapse buttons and RequestListeners to respond on user actions.

An extension is initialized once when the compnent is created. During initialization it may register decorators with the renderer and/or RequestListeners with the table component. The extensions are listed in confix.xml

Renderer

The TableRenderer creates a DOM representation of the olap data. In the GOF builder pattern, it plays the role of the director. It delegates the construction of elements like cells, axes etc to PartBuilders. PartBuilder may be decorated (mostly by extensions).

Axes

Spans and Axes

Axes are seen as a matrix of spans, the axes of this matrix are positions and hierarchies. For a row-axis, the positions are the rows, the hierarchies are the columns, for a column-axis its vice versa.

How to add a CellBuilder extension

Instead of deriving from CellBuilder you better create a {@link TableComponentExtension} by deriving from {@link TableComponentExtensionSupport}. In its initialize() method you add a decorator to the tables CellBuilder. The decorator will extend {@link CellBuilderDecorator}. Finally you register the extension in jpivot/table/config.xml

Example Extension:

public class MyTableExtension extends TableComponentExtensionSupport {

  public static final String ID = "myextension";

  public String getId() {
    return ID;
  }

  public void initialize(RequestContext context, TableComponent table) throws Exception {
    super.initialize(context, table);
    MyCellBuilderDecorator cbd = new MyCellBuilderDecorator(table.getCellBuilder());
    table.setCellBuilder(cbd);
  }
  ...
}
The ID is used to access the extension from JSP pages via JSTL Expression Language.

Example of a CellBuilderDecorator:

public class MyCellBuilderDecorator extends CellBuilderDecorator {

  public MyCellBuilderDecorator(CellBuilder delegate) {
    super(delegate);
  }

  public Element build(Cell cell, boolean even) {
    Element el = super.build(cell, even);

    // add your attributes or children here

    return el;
  }

  public void startBuild(RequestContext context) {
    super.startBuild(context);
    // initialisation stuff goes here
  }

  public void stopBuild() {
    // clean up stuff goes here
    super.stopBuild();
  }
}

Example registering the extension with the table component in config.xml:

<table class="com.tonbeller.jpivot.table.TableComponent">
  <cellBuilder class="com.tonbeller.jpivot.table.CellBuilderImpl"/>
  ...
  <extension class="my.package.MyTableExtension"/>
</table>