org.displaytag.decorator
Class MultilevelTotalTableDecorator

java.lang.Object
  extended by org.displaytag.decorator.TableDecorator
      extended by org.displaytag.decorator.MultilevelTotalTableDecorator

public class MultilevelTotalTableDecorator
extends TableDecorator

A TableDecorator that, in conjunction with totaled and grouped columns, produces multi level subtotals on arbitrary String groupings. Use it directly, subclass it, or use it as an example to better meet your local needs.

Author:
rapruitt, Fabrizio Giustina

Field Summary
protected  java.lang.String grandTotalDescription
          Grandtotal description.
protected  java.lang.String grandTotalLabel
          CSS class applied to grand total lablels.
protected  java.lang.String grandTotalNoSum
          CSS class applied to grand total cells where the column is not totaled.
protected  java.lang.String grandTotalSum
          CSS class applied to grand total totals.
protected  int innermostGroup
          Controls when the subgroup is ended.
protected  TableModel tableModel
          The table model.
 
Constructor Summary
MultilevelTotalTableDecorator()
           
 
Method Summary
protected  java.lang.Object add(Column column, java.lang.Object total, java.lang.Object value)
           
 java.lang.String displayGroupedValue(java.lang.String value, 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 groupNumber)
          Called at the end of a group.
 java.lang.String finishRow()
          Called at the end of a row.
 java.lang.String formatTotal(HeaderCell header, java.lang.Object total)
           
protected  java.lang.String getCellValue(int columnNumber, int rowNumber)
           
 java.lang.Object getDecoratedObject()
          returns the decorated object.
 java.lang.String getGrandTotalDescription()
           
 java.lang.String getGrandTotalLabel()
           
 java.lang.String getGrandTotalNoSum()
           
 java.lang.String getGrandTotalSum()
           
 javax.servlet.jsp.PageContext getPageContext()
          returns the page context.
 java.lang.String getSubtotalHeaderClass()
           
 java.lang.String getSubtotalLabelClass()
           
 java.lang.String getSubtotalValueClass()
           
protected  java.lang.Object getTotalForColumn(int columnNumber, int startRow, int stopRow)
           
 java.lang.String getTotalRowLabel(java.lang.String groupingValue)
           
 java.lang.String getTotalsRowOpen()
           
 java.lang.String getTotalsTdOpen(HeaderCell header, java.lang.String totalClass)
           
 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 context, java.lang.Object decorated, TableModel model)
          Initialize the TableTecorator instance.
 boolean searchGetterFor(java.lang.String propertyName)
          Looks for a getter for the given property using introspection.
 void setGrandTotalDescription(java.lang.String grandTotalDescription)
           
 void setGrandTotalLabel(java.lang.String grandTotalLabel)
           
 void setGrandTotalNoSum(java.lang.String grandTotalNoSum)
           
 void setGrandTotalSum(java.lang.String grandTotalSum)
           
 void setSubtotalHeaderClass(java.lang.String subtotalHeaderClass)
           
 void setSubtotalLabel(java.lang.String pattern, java.util.Locale locale)
          The pattern to use to generate the subtotal labels.
 void setSubtotalLabelClass(java.lang.String subtotalLabelClass)
           
 void setSubtotalValueClass(java.lang.String subtotalValueClass)
           
 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.
protected  java.lang.String totalAllRows()
          Issue a grand total row at the bottom.
 
Methods inherited from class org.displaytag.decorator.TableDecorator
addRowClass, addRowId, evaluate, finish, getCurrentRowObject, getListIndex, getViewIndex, initRow, isLastRow
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

innermostGroup

protected int innermostGroup
Controls when the subgroup is ended.


grandTotalSum

protected java.lang.String grandTotalSum
CSS class applied to grand total totals.


grandTotalNoSum

protected java.lang.String grandTotalNoSum
CSS class applied to grand total cells where the column is not totaled.


grandTotalLabel

protected java.lang.String grandTotalLabel
CSS class applied to grand total lablels.


grandTotalDescription

protected java.lang.String grandTotalDescription
Grandtotal description.


tableModel

protected TableModel tableModel
The table model.

Since:
1.1
Constructor Detail

MultilevelTotalTableDecorator

public MultilevelTotalTableDecorator()
Method Detail

init

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

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

getGrandTotalDescription

public java.lang.String getGrandTotalDescription()

setGrandTotalDescription

public void setGrandTotalDescription(java.lang.String grandTotalDescription)

setSubtotalLabel

public void setSubtotalLabel(java.lang.String pattern,
                             java.util.Locale locale)
The pattern to use to generate the subtotal labels. The grouping value of the cell will be the first arg. The default value is "{0} Total".

Parameters:
pattern -
locale -

getGrandTotalLabel

public java.lang.String getGrandTotalLabel()

getGrandTotalSum

public java.lang.String getGrandTotalSum()

getGrandTotalNoSum

public java.lang.String getGrandTotalNoSum()

setGrandTotalNoSum

public void setGrandTotalNoSum(java.lang.String grandTotalNoSum)

setGrandTotalSum

public void setGrandTotalSum(java.lang.String grandTotalSum)

setGrandTotalLabel

public void setGrandTotalLabel(java.lang.String grandTotalLabel)

getSubtotalValueClass

public java.lang.String getSubtotalValueClass()

setSubtotalValueClass

public void setSubtotalValueClass(java.lang.String subtotalValueClass)

getSubtotalLabelClass

public java.lang.String getSubtotalLabelClass()

setSubtotalLabelClass

public void setSubtotalLabelClass(java.lang.String subtotalLabelClass)

getSubtotalHeaderClass

public java.lang.String getSubtotalHeaderClass()

setSubtotalHeaderClass

public void setSubtotalHeaderClass(java.lang.String subtotalHeaderClass)

startOfGroup

public void startOfGroup(java.lang.String value,
                         int group)
Description copied from class: TableDecorator
Indicates that we are begining a new group.

Overrides:
startOfGroup in class TableDecorator
Parameters:
value - of the current cell
group - number of the current column

displayGroupedValue

public java.lang.String displayGroupedValue(java.lang.String value,
                                            short groupingStatus,
                                            int columnNumber)
Description copied from class: TableDecorator
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.

Overrides:
displayGroupedValue in class TableDecorator
Returns:
the value to display

startRow

public java.lang.String startRow()
Description copied from class: TableDecorator
Called at the beginning of a row. Can be subclassed to provide specific data at the beginning of a row

Overrides:
startRow in class TableDecorator
Returns:
null in the default implementation

endOfGroup

public void endOfGroup(java.lang.String value,
                       int groupNumber)
Description copied from class: TableDecorator
Called at the end of a group. Can be subclassed to provide specific data at the end of a row.

Overrides:
endOfGroup in class TableDecorator
Parameters:
value - of the current cell
groupNumber - number of the current column

finishRow

public java.lang.String finishRow()
Description copied from class: TableDecorator
Called at the end of a row. Can be subclassed to provide specific data at the end of a row

Overrides:
finishRow in class TableDecorator
Returns:
null in the default implementation

totalAllRows

protected java.lang.String totalAllRows()
Issue a grand total row at the bottom.

Returns:
the suitable string

getCellValue

protected java.lang.String getCellValue(int columnNumber,
                                        int rowNumber)

getTotalForColumn

protected java.lang.Object getTotalForColumn(int columnNumber,
                                             int startRow,
                                             int stopRow)

add

protected java.lang.Object add(Column column,
                               java.lang.Object total,
                               java.lang.Object value)

getTotalsTdOpen

public java.lang.String getTotalsTdOpen(HeaderCell header,
                                        java.lang.String totalClass)

getTotalsRowOpen

public java.lang.String getTotalsRowOpen()

getTotalRowLabel

public java.lang.String getTotalRowLabel(java.lang.String groupingValue)

formatTotal

public java.lang.String formatTotal(HeaderCell header,
                                    java.lang.Object total)

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)

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.