org.displaytag.decorator
Class TableDecorator

java.lang.Object
  extended by org.displaytag.decorator.TableDecorator
Direct Known Subclasses:
MultilevelTotalTableDecorator, TotalTableDecorator

public abstract class TableDecorator
extends java.lang.Object

Version:
$Revision: 1084 $ ($Author: fgiust $)
Author:
epesh, Fabrizio Giustina

Field Summary
protected  TableModel tableModel
          The table model.
 
Constructor Summary
TableDecorator()
           
 
Method Summary
 java.lang.String addRowClass()
          Call back to add an additional row class to the current row.
 java.lang.String addRowId()
          Call back to allow setting an "id" attribute on a row.
 java.lang.String displayGroupedValue(java.lang.String cellValue, short groupingStatus, int columnNumber)
          What value should I display in this cell? The default value for grouped columns is to not display any value if the cellValue has not changed on an interior iteration.
 void endOfGroup(java.lang.String value, int groupThatHasEnded)
          Called at the end of a group.
protected  java.lang.Object evaluate(java.lang.String propertyName)
          Shortcut for evaluating properties in the current row object.
 void finish()
          Called at the end of evaluation.
 java.lang.String finishRow()
          Called at the end of a row.
 java.lang.Object getCurrentRowObject()
          Get the object representing the current row.
 java.lang.Object getDecoratedObject()
          returns the decorated object.
 int getListIndex()
          Return the index in the full list (view index + offset).
 javax.servlet.jsp.PageContext getPageContext()
          returns the page context.
 int getViewIndex()
          Return the index in the displayed list.
 boolean hasGetterFor(java.lang.String propertyName)
          Check if a getter exists for a given property.
 void init(javax.servlet.jsp.PageContext pageContext, java.lang.Object decorated)
          Deprecated. use #init(PageContext, Object, TableModel)
 void init(javax.servlet.jsp.PageContext pageContext, java.lang.Object decorated, TableModel tableModel)
          Initialize the TableTecorator instance.
 void initRow(java.lang.Object rowObject, int currentViewIndex, int currentListIndex)
          Initialize the current row.
 boolean isLastRow()
           
 boolean searchGetterFor(java.lang.String propertyName)
          Looks for a getter for the given property using introspection.
 void startOfGroup(java.lang.String value, int group)
          Indicates that we are begining a new group.
 java.lang.String startRow()
          Called at the beginning of a row.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tableModel

protected TableModel tableModel
The table model.

Since:
1.1
Constructor Detail

TableDecorator

public TableDecorator()
Method Detail

getViewIndex

public final int getViewIndex()
Return the index in the displayed list.

Returns:
int index in the displayed list

getListIndex

public final int getListIndex()
Return the index in the full list (view index + offset). Note that the index returned if from the sorted list, and not from the original one.

Returns:
int index in the full list

getCurrentRowObject

public final java.lang.Object getCurrentRowObject()
Get the object representing the current row.

Returns:
Object

initRow

public final void initRow(java.lang.Object rowObject,
                          int currentViewIndex,
                          int currentListIndex)
Initialize the current row. Note this method is also called when sorting a table using a property supplied by the table decorator, so the method could be called multiple times during rendering. When used to initialize sorting the method is always called with 0, 0 as currentViewIndex and currentListIndex.

Parameters:
rowObject - object representing the current row
currentViewIndex - int index in the displayed list
currentListIndex - int index in the original list

startRow

public java.lang.String startRow()
Called at the beginning of a row. Can be subclassed to provide specific data at the beginning of a row

Returns:
null in the default implementation

finishRow

public java.lang.String finishRow()
Called at the end of a row. Can be subclassed to provide specific data at the end of a row

Returns:
null in the default implementation

finish

public void finish()
Called at the end of evaluation. Can be subclassed to eventully clean up data. Always remember to also call super.finish()!


addRowClass

public java.lang.String addRowClass()
Call back to add an additional row class to the current row.

Returns:
CSS class attribute value for the current row
Since:
1.1

addRowId

public java.lang.String addRowId()
Call back to allow setting an "id" attribute on a row.

Returns:
HTML id attribute value for the current row
Since:
1.1

startOfGroup

public void startOfGroup(java.lang.String value,
                         int group)
Indicates that we are begining a new group.

Parameters:
value - of the current cell
group - number of the current column

endOfGroup

public void endOfGroup(java.lang.String value,
                       int groupThatHasEnded)
Called at the end of a group. Can be subclassed to provide specific data at the end of a row.

Parameters:
value - of the current cell
groupThatHasEnded - number of the current column

displayGroupedValue

public java.lang.String displayGroupedValue(java.lang.String cellValue,
                                            short groupingStatus,
                                            int columnNumber)
What value should I display in this cell? The default value for grouped columns is to not display any value if the cellValue has not changed on an interior iteration. Only invoked for columns that are grouped.

Parameters:
cellValue -
groupingStatus -
Returns:
the value to display

isLastRow

public boolean isLastRow()

evaluate

protected java.lang.Object evaluate(java.lang.String propertyName)
Shortcut for evaluating properties in the current row object. Can be useful for implementing anonymous decorators in jsp pages without having to know/import the decorated object Class.

Parameters:
propertyName - property to lookup in current row object. Can also be a nested or indexed property.
Since:
1.1

init

public void init(javax.servlet.jsp.PageContext pageContext,
                 java.lang.Object decorated)
Deprecated. use #init(PageContext, Object, TableModel)

Initialize the TableTecorator instance.

Parameters:
pageContext - PageContext
decorated - decorated object (usually a list)
See Also:
init(PageContext, Object, TableModel)

init

public void init(javax.servlet.jsp.PageContext pageContext,
                 java.lang.Object decorated,
                 TableModel tableModel)
Initialize the TableTecorator instance.

Parameters:
pageContext - PageContext
decorated - decorated object (usually a list)
tableModel - table model

getPageContext

public javax.servlet.jsp.PageContext getPageContext()
returns the page context.

Returns:
PageContext

getDecoratedObject

public java.lang.Object getDecoratedObject()
returns the decorated object.

Returns:
Object

hasGetterFor

public boolean hasGetterFor(java.lang.String propertyName)
Check if a getter exists for a given property. Uses cached info if property has already been requested. This method only check for a simple property, if pPropertyName contains multiple tokens only the first part is evaluated

Parameters:
propertyName - name of the property to check
Returns:
boolean true if the decorator has a getter for the given property

searchGetterFor

public boolean searchGetterFor(java.lang.String propertyName)
Looks for a getter for the given property using introspection.

Parameters:
propertyName - name of the property to check
Returns:
boolean true if the decorator has a getter for the given property


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