D - The class name of the model object backing this table model.public class JDOTableModel<D extends Serializable> extends DefaultPageableTableModel<D> implements SortableTableModel
PersistenceCapable object. Provides
generic implementation of pagination and sorting algorithms.
Note This model assumes that the ApplicationInstance.getActive() returns an instance of
JDOApplication. The
PersistenceManager to use to interact with the data
store is fetched from this application instance.
The following shows sample usage of this class:
import nextapp.echo.app.Column;
import com.sptci.echo.table.JDOTable;
import com.sptci.echo.table.JDOTableModel;
import com.sptci.echo.table.TableNavigation;
...
final MyJDOObject obj = new MyJDOObject();
JDOTableModel<MyJDOObject> model = new JDOTableModel<MyJDOObject>( obj );
model.init(); // This is mandatory
JDOTable<MyJDOObject> table = new JDOTable<MyJDOObject>( model );
Column column = new Column();
column.add( new TableNavigation<MyJDOObject>( model ) );
column.add( table );
© Copyright 2008 Sans Pareil Technologies, Inc.
SortableTableModel.Direction| Modifier and Type | Field and Description |
|---|---|
protected boolean |
initialised
A flag used to indicate whether this model has been initialised or
not.
|
protected D |
model
A dummy object maintained to introspect and fetch persistent instances
|
page, pageSize, totalRowscolumns, datasortDirection, sortIndex| Modifier | Constructor and Description |
|---|---|
protected |
JDOTableModel()
Default constructor.
|
|
JDOTableModel(D model)
Create a new table model for objects of the specified type.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addRow(D row)
Add the specified object to the end of the model.
|
void |
deleteRow(int row)
Delete the specified row from the model.
|
protected void |
fetchData()
Fetch the data for the current
DefaultPageableTableModel.page from the data store. |
protected Object |
fetchRepository()
Fetch the repository class for the
model. |
protected void |
fetchSortedData()
Fetch the data for the current
DefaultPageableTableModel.page from the data store sorted
by AbstractTableModel.sortIndex in AbstractTableModel.sortDirection. |
protected void |
fetchUnsortedData()
Fetch the data for the current
DefaultPageableTableModel.page from the data store. |
void |
init()
Initialise the table model.
|
protected void |
initTotalRows()
Initialise the
DefaultPageableTableModel.totalRows field with the total number of
persistent instances of model. |
void |
insertRow(int row,
D rowData)
Insert the specified object at the specified row index into the model.
|
void |
setPage(int page)
Sets the value of
DefaultPageableTableModel.page. |
void |
setPageSize(int pageSize)
Sets the value of
DefaultPageableTableModel.pageSize. |
void |
sort(int column)
Sort the data by the values in the specified column index.
|
void |
sort(int column,
SortableTableModel.Direction direction)
Sort the data by the values in the specified column index.
|
protected void |
sortData()
Perform a default sort of the displayable data since the column
selected cannot be sorted through the data store.
|
getPage, getPageSize, getTotalPages, setPageSizedeleteRow, getColumnAnnotations, getColumnClass, getColumnCount, getColumnName, getObjectAt, getRowCount, getValueAt, processColumnAnnotations, processColumns, processColumnsAnnotation, processFields, updateRowgetSortDirectionaddTableModelListener, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getEventListenerList, removeTableModelListenerclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetSortDirectionprotected final D extends Serializable model
protected boolean initialised
protected JDOTableModel()
public JDOTableModel(D model)
init() for table model to be initialised.model - A dummy object used to initialise the table model. Note
that the dummy object need not be a persistent instance.init()public void init()
DefaultPageableTableModel.pageSize, DefaultPageableTableModel.page etc. initially without forcing
the model to refresh data from the data store.init in class DefaultPageableTableModel<D extends Serializable>TableModel.processColumns(),
initTotalRows(),
fetchData()protected Object fetchRepository() throws Throwable
model.Throwable - If any errors are encountered while fetch the
repository instance.protected void initTotalRows()
DefaultPageableTableModel.totalRows field with the total number of
persistent instances of model.protected void fetchData()
DefaultPageableTableModel.page from the data store.protected void fetchUnsortedData()
DefaultPageableTableModel.page from the data store. Note
that this method assumes that clearing TableModel.data and firing table
update events are handled by fetchData().setPageSize(int),
setPage(int)protected void fetchSortedData()
DefaultPageableTableModel.page from the data store sorted
by AbstractTableModel.sortIndex in AbstractTableModel.sortDirection. Note that this
method assumes that clearing TableModel.data and firing table update
events are handled by fetchData(). If the data store throws
an exception when sorting using this method (complex sorting requires
special JDOQL that is not supported by this method), then sorting is
done through the sortData() method after refreshing the data
using fetchUnsortedData().protected void sortData()
public void setPage(int page)
DefaultPageableTableModel.page.setPage in interface PageableTableModelpage - The current page of data to load in the model.PageableTableModel.setPage(int),
fetchData()public void setPageSize(int pageSize)
DefaultPageableTableModel.pageSize.setPageSize in interface PageableTableModelpageSize - The number of rows to display in the model.RuntimeException - If SQLException is raised
by fetchData().PageableTableModel.setPageSize(int),
fetchData()public void sort(int column)
sort in interface SortableTableModelcolumn - The index of the column by which the data is to
be sorted.AbstractTableModel.getSortDirection(int),
SortableTableModel.sort( int, Direction )public void sort(int column,
SortableTableModel.Direction direction)
sort in interface SortableTableModelcolumn - The index of the column by which the data is to
be sorted.direction - The direction of sorting to be applied.AbstractTableModel.fireTableDataChanged()public void addRow(D row)
DefaultPageableTableModel.totalRows.addRow in class TableModel<D extends Serializable>row - The data object that is to be added to the model.TableModel.addRow(D)public void insertRow(int row,
D rowData)
DefaultPageableTableModel.totalRows.insertRow in class TableModel<D extends Serializable>row - The index at which the object is to be inserted.rowData - The object that is to be added to the model.TableModel.insertRow(int, D)public void deleteRow(int row)
deleteRow in class TableModel<D extends Serializable>row - The index of the row that is to be deleted.TableModel.deleteRow( int ),
initTotalRows(),
fetchData()