SPT RWT Application API

com.sptci.rwt.webui
Class RowTableModel

java.lang.Object
  extended by nextapp.echo2.app.table.AbstractTableModel
      extended by com.sptci.echo2.table.AbstractTableModel<D>
          extended by com.sptci.echo2.table.TableModel<D>
              extended by com.sptci.echo2.table.DefaultPageableTableModel<Row>
                  extended by com.sptci.rwt.webui.RowTableModel
All Implemented Interfaces:
com.sptci.echo2.table.PageableTableModel, Serializable, TableModel
Direct Known Subclasses:
RowsTableModel, SortableRowTableModel

public class RowTableModel
extends com.sptci.echo2.table.DefaultPageableTableModel<Row>

A custom table model used to display Row objects.

© Copyright 2007 Sans Pareil Technologies, Inc.

Version:
$Id: RowTableModel.java 4123 2008-05-25 21:49:01Z rakesh $
Author:
Rakesh Vidyadharan 2007-10-04
See Also:
Serialized Form

Field Summary
protected  ConnectionManager manager
          The connection manager to use to fetch database connections.
protected  int maxColumnLength
          The maximum number of characters to display in a column.
protected  int maxRows
          The maximum number of records to fetch from the database.
protected  String query
          The SQL statement that is to be executed to fetch the results.
 
Fields inherited from class com.sptci.echo2.table.DefaultPageableTableModel
page, pageSize, totalRows
 
Fields inherited from class com.sptci.echo2.table.TableModel
columns, data
 
Fields inherited from class com.sptci.echo2.table.AbstractTableModel
sortDirection, sortIndex
 
Constructor Summary
protected RowTableModel()
          Default constructor.
  RowTableModel(String query, int maxRows, int maxColumnLength, ConnectionManager manager)
          Create a new instance of the table model using the specified collection of Row objects.
 
Method Summary
protected  void fetchData()
          Fetch the data from the database by executing query.
 String getColumnName(int column)
          Return the column name to display at the specified index.
 ConnectionManager getManager()
          Returns manager.
 int getMaxColumnLength()
          Returns maxColumnLength.
 int getMaxRows()
          Returns maxRows.
 String getQuery()
          Returns query.
 long getTotalRows()
          Returns DefaultPageableTableModel.totalRows.
 Object getValueAt(int column, int row)
          Return the value to display at the coordinates specified.
protected  void processColumns()
          Over-ridden to set the proper column meta data using the column information from the row object.
 void setPage(int page)
          Set DefaultPageableTableModel.page.
 void setPageSize(int pageSize)
          Set DefaultPageableTableModel.pageSize.
 
Methods inherited from class com.sptci.echo2.table.DefaultPageableTableModel
getPage, getPageSize, getTotalPages
 
Methods inherited from class com.sptci.echo2.table.TableModel
addRow, deleteRow, deleteRow, getColumnAnnotations, getColumnClass, getColumnCount, getObjectAt, getRowCount, init, insertRow, processColumnAnnotations, processColumnsAnnotation, processFields, updateRow
 
Methods inherited from class com.sptci.echo2.table.AbstractTableModel
getSortDirection
 
Methods inherited from class nextapp.echo2.app.table.AbstractTableModel
addTableModelListener, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getEventListenerList, removeTableModelListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

query

protected final String query
The SQL statement that is to be executed to fetch the results.


maxRows

protected final int maxRows
The maximum number of records to fetch from the database.


maxColumnLength

protected final int maxColumnLength
The maximum number of characters to display in a column.

Since:
Version 1.3

manager

protected final ConnectionManager manager
The connection manager to use to fetch database connections.

Constructor Detail

RowTableModel

protected RowTableModel()
Default constructor. No special actions required.

Since:
Version 1.2

RowTableModel

public RowTableModel(String query,
                     int maxRows,
                     int maxColumnLength,
                     ConnectionManager manager)
              throws QueryException
Create a new instance of the table model using the specified collection of Row objects.

Parameters:
query - The sql statement that is to be executed to fetch any additional pages of data.
maxRows - The maximum number of rows to fetch from the result set.
maxColumnLength - The maximum number of characters to display in a column.
manager - The manager to use to fetch database connections.
Throws:
QueryException - If errors are encountered while executing the query.
See Also:
fetchData(), processColumns()
Method Detail

fetchData

protected void fetchData()
                  throws QueryException
Fetch the data from the database by executing query.

Throws:
QueryException - If errors are encountered while executing the query.
See Also:
AbstractTableModel.fireTableDataChanged(), QueryExecutor

processColumns

protected void processColumns()
Over-ridden to set the proper column meta data using the column information from the row object.

Overrides:
processColumns in class com.sptci.echo2.table.TableModel<Row>

getColumnName

public String getColumnName(int column)
Return the column name to display at the specified index.

Specified by:
getColumnName in interface TableModel
Overrides:
getColumnName in class com.sptci.echo2.table.TableModel<Row>
Parameters:
column - The column index for which the name is required.
Returns:
The name of the column.

getValueAt

public Object getValueAt(int column,
                         int row)
Return the value to display at the coordinates specified.

Specified by:
getValueAt in interface TableModel
Overrides:
getValueAt in class com.sptci.echo2.table.TableModel<Row>
Parameters:
column - The column index.
row - The row index.
Returns:
The value for the coordinates.
Throws:
RuntimeException - If the indices are invalid.

getQuery

public String getQuery()
Returns query.

Returns:
The value/reference of/to query.

getMaxRows

public int getMaxRows()
Returns maxRows.

Returns:
The value/reference of/to maxRows.

getMaxColumnLength

public int getMaxColumnLength()
Returns maxColumnLength.

Returns:
The value/reference of/to maxColumnLength.
Since:
Version 1.3

getManager

public ConnectionManager getManager()
Returns manager.

Returns:
The value/reference of/to manager.

getTotalRows

public long getTotalRows()
Returns DefaultPageableTableModel.totalRows.

Returns:
The value/reference of/to totalRows.

setPage

public void setPage(int page)
Set DefaultPageableTableModel.page.

Parameters:
page - The value to set.
See Also:
fetchData()

setPageSize

public void setPageSize(int pageSize)
Set DefaultPageableTableModel.pageSize.

Parameters:
pageSize - The value to set.
See Also:
fetchData()

SPT RWT Application API