org.apache.tapestry.contrib.table.model.sql
Class SqlTableModel

java.lang.Object
  extended by org.apache.tapestry.contrib.table.model.common.AbstractTableModel
      extended by org.apache.tapestry.contrib.table.model.sql.SqlTableModel
All Implemented Interfaces:
Serializable, ITableModel

public class SqlTableModel
extends AbstractTableModel

An implementation of ITableModel that obtains its data through SQL queries. This is a very efficient model, since it uses SQL to perform the data sorting (through ORDER BY) and obtains only the data on the current page (through LIMIT/OFFSET).

This object is typically created in the following manner:

 
    ISqlConnectionSource objConnSrc = 
        new SimpleSqlConnectionSource("jdbc:postgresql://localhost/testdb", "testdb", "testdb");

    ISqlTableDataSource objDataSrc = 
        new SimpleSqlTableDataSource(objConnSrc, "test_table");

    SqlTableColumnModel objColumnModel = 
        new SqlTableColumnModel(new SqlTableColumn[] {
            new SqlTableColumn("language", "Language", true),
            new SqlTableColumn("country", "Country", true),
            new SqlTableColumn("variant", "Variant", true),
            new SqlTableColumn("intvalue", "Integer", true),
            new SqlTableColumn("floatvalue", "Float", true)
        });

    ITableModel objTableModel = new SqlTableModel(objDataSrc, objColumnModel);

    return objTableModel;
 

Version:
$Id: SqlTableModel.java 243791 2004-02-19 17:38:13Z hlship $
Author:
mindbridge
See Also:
Serialized Form

Constructor Summary
SqlTableModel(ISqlTableDataSource objDataSource, SqlTableColumnModel objColumnModel)
           
SqlTableModel(ISqlTableDataSource objDataSource, SqlTableColumnModel objColumnModel, SimpleTableState objState)
           
 
Method Summary
 ITableColumnModel getColumnModel()
          Method getColumnModel.
 Iterator getCurrentPageRows()
          Method getCurrentPageRows.
protected  int getRowCount()
           
 SqlTableColumnModel getSqlColumnModel()
           
 ISqlTableDataSource getSqlDataSource()
          Returns the dataSource.
 
Methods inherited from class org.apache.tapestry.contrib.table.model.common.AbstractTableModel
getPageCount, getPagingState, getSortingState, getState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SqlTableModel

public SqlTableModel(ISqlTableDataSource objDataSource,
                     SqlTableColumnModel objColumnModel)

SqlTableModel

public SqlTableModel(ISqlTableDataSource objDataSource,
                     SqlTableColumnModel objColumnModel,
                     SimpleTableState objState)
Method Detail

getColumnModel

public ITableColumnModel getColumnModel()
Description copied from interface: ITableModel
Method getColumnModel.

Returns:
ITableColumnModel the column model of the table
See Also:
ITableModel.getColumnModel()

getSqlColumnModel

public SqlTableColumnModel getSqlColumnModel()

getCurrentPageRows

public Iterator getCurrentPageRows()
Description copied from interface: ITableModel
Method getCurrentPageRows.

Returns:
Iterator the rows in the current table page given the current data, sorting, and paging state
See Also:
ITableModel.getCurrentPageRows()

getSqlDataSource

public ISqlTableDataSource getSqlDataSource()
Returns the dataSource.

Returns:
ISqlTableDataSource

getRowCount

protected int getRowCount()
Specified by:
getRowCount in class AbstractTableModel
See Also:
AbstractTableModel.getRowCount()