org.displaytag.model
Class TableModel

java.lang.Object
  extended by org.displaytag.model.TableModel

public class TableModel
extends java.lang.Object

Table Model. Holds table data for presentation.

Version:
$Revision: 1081 $ ($Author: fgiust $)
Author:
Fabrizio Giustina

Constructor Summary
TableModel(TableProperties tableProperties, java.lang.String charEncoding, javax.servlet.jsp.PageContext pageContext)
          Constructor for TableModel.
 
Method Summary
 void addColumnHeader(HeaderCell headerCell)
          Adds a column header (HeaderCell object).
 void addRow(Row row)
          adds a Row object to the table.
 java.lang.String getCaption()
          Obtain this table's caption.
 java.lang.String getEncoding()
          Getter for character encoding.
 java.lang.String getFooter()
          Obtain this table's footer.
 java.util.List getHeaderCellList()
          List containing headerCell objects.
 java.lang.String getId()
          get the table id.
 MediaTypeEnum getMedia()
          Gets the current media type.
 int getNumberOfColumns()
          return the number of columns in the table.
protected  javax.servlet.jsp.PageContext getPageContext()
          Returns the jsp page context.
 TableProperties getProperties()
          Returns the table properties.
 RowIterator getRowIterator(boolean full)
          returns a RowIterator on the requested (full|page) list.
 java.util.List getRowListFull()
          get the full list.
 java.util.List getRowListPage()
          gets the partial (paginated) list.
 HeaderCell getSortedColumnHeader()
          returns the HeaderCell for the sorted column.
 int getSortedColumnNumber()
          return the index of the sorted column.
 TableDecorator getTableDecorator()
          getter for the Table Decorator.
 boolean isEmpty()
          return true is the table has no columns.
 boolean isLocalSort()
           
 boolean isSorted()
          returns true if the table is sorted.
 boolean isSortFullTable()
          return the sort full table property.
 boolean isSortOrderAscending()
          return the sort order of the page.
 void setCaption(java.lang.String caption)
          Set this table's caption.
 void setFooter(java.lang.String footer)
          Set this table's footer.
 void setId(java.lang.String tableId)
          Setter for the tablemodel id.
 void setLocalSort(boolean localSort)
          Sets whether the table performs local in memory sorting of the data.
 void setMedia(MediaTypeEnum media)
          sets the current media type.
 void setPageOffset(int offset)
          Sets the starting offset for elements in the viewable list.
 void setRowListPage(java.util.List rowList)
           
 void setSortedColumnName(java.lang.String sortedColumnName)
          sets the name of the currently sorted column
 void setSortedColumnNumber(int sortIndex)
          set the sorted column index.
 void setSortFullTable(boolean sortFull)
          sets the sort full table property.
 void setSortOrderAscending(boolean isSortOrderAscending)
          set the sort order of the list.
 void setTableDecorator(TableDecorator decorator)
          setter for the table decorator.
 void sortFullList()
          sort the full list of data.
 void sortPageList()
          sort the list displayed in page.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TableModel

public TableModel(TableProperties tableProperties,
                  java.lang.String charEncoding,
                  javax.servlet.jsp.PageContext pageContext)
Constructor for TableModel.

Parameters:
tableProperties - table properties
charEncoding - response encoding
Method Detail

getPageContext

protected javax.servlet.jsp.PageContext getPageContext()
Returns the jsp page context.

Returns:
page context

getMedia

public MediaTypeEnum getMedia()
Gets the current media type.

Returns:
current media (html, pdf ...)

setMedia

public void setMedia(MediaTypeEnum media)
sets the current media type.

Parameters:
media - current media (html, pdf ...)

setLocalSort

public void setLocalSort(boolean localSort)
Sets whether the table performs local in memory sorting of the data.

Parameters:
localSort -

isLocalSort

public boolean isLocalSort()
Returns:
sorting in local memory

setPageOffset

public void setPageOffset(int offset)
Sets the starting offset for elements in the viewable list.

Parameters:
offset - The page offset to set.

setId

public void setId(java.lang.String tableId)
Setter for the tablemodel id.

Parameters:
tableId - same id of table tag, needed for logging

getId

public java.lang.String getId()
get the table id.

Returns:
table id

getRowListFull

public java.util.List getRowListFull()
get the full list.

Returns:
the full list containing Row objects

getRowListPage

public java.util.List getRowListPage()
gets the partial (paginated) list.

Returns:
the partial list to display in page (contains Row objects)

addRow

public void addRow(Row row)
adds a Row object to the table.

Parameters:
row - Row

setSortedColumnName

public void setSortedColumnName(java.lang.String sortedColumnName)
sets the name of the currently sorted column

Parameters:
sortedColumnName -

setSortFullTable

public void setSortFullTable(boolean sortFull)
sets the sort full table property. If true the full list is sorted, if false sorting is applied only to the displayed sublist.

Parameters:
sortFull - boolean

isSortFullTable

public boolean isSortFullTable()
return the sort full table property.

Returns:
boolean true if sorting is applied to the full list

isSortOrderAscending

public boolean isSortOrderAscending()
return the sort order of the page.

Returns:
true if sort order is ascending

setSortOrderAscending

public void setSortOrderAscending(boolean isSortOrderAscending)
set the sort order of the list.

Parameters:
isSortOrderAscending - true to sort in ascending order

setRowListPage

public void setRowListPage(java.util.List rowList)
Parameters:
rowList - - the new value for this.rowListPage

getTableDecorator

public TableDecorator getTableDecorator()
getter for the Table Decorator.

Returns:
TableDecorator

setTableDecorator

public void setTableDecorator(TableDecorator decorator)
setter for the table decorator.

Parameters:
decorator - - the TableDecorator object

isSorted

public boolean isSorted()
returns true if the table is sorted.

Returns:
boolean true if the table is sorted

getSortedColumnHeader

public HeaderCell getSortedColumnHeader()
returns the HeaderCell for the sorted column.

Returns:
HeaderCell

getNumberOfColumns

public int getNumberOfColumns()
return the number of columns in the table.

Returns:
int number of columns

isEmpty

public boolean isEmpty()
return true is the table has no columns.

Returns:
boolean

getSortedColumnNumber

public int getSortedColumnNumber()
return the index of the sorted column.

Returns:
index of the sorted column or -1 if the table is not sorted

setSortedColumnNumber

public void setSortedColumnNumber(int sortIndex)
set the sorted column index.

Parameters:
sortIndex - - the index of the sorted column

addColumnHeader

public void addColumnHeader(HeaderCell headerCell)
Adds a column header (HeaderCell object).

Parameters:
headerCell - HeaderCell

getHeaderCellList

public java.util.List getHeaderCellList()
List containing headerCell objects.

Returns:
List containing headerCell objects

getRowIterator

public RowIterator getRowIterator(boolean full)
returns a RowIterator on the requested (full|page) list.

Parameters:
full - if true returns an iterator on te full list, if false only on the viewable part.
Returns:
RowIterator
See Also:
RowIterator

sortPageList

public void sortPageList()
sort the list displayed in page.


sortFullList

public void sortFullList()
sort the full list of data.


getProperties

public TableProperties getProperties()
Returns the table properties.

Returns:
the configured table properties.

getEncoding

public java.lang.String getEncoding()
Getter for character encoding.

Returns:
Returns the encoding used for response.

getCaption

public java.lang.String getCaption()
Obtain this table's caption.

Returns:
This table's caption.

setCaption

public void setCaption(java.lang.String caption)
Set this table's caption.

Parameters:
caption - This table's caption.

getFooter

public java.lang.String getFooter()
Obtain this table's footer.

Returns:
This table's footer.

setFooter

public void setFooter(java.lang.String footer)
Set this table's footer.

Parameters:
footer - This table's footer.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()


Copyright © 2002-2007 the Displaytag team. All Rights Reserved.