View source
City Project Amount Count
Carthago Army 661.00 $ 1
Taxes 242.00 $ 0
Taxes 714.00 $ 4
Neapolis Army 540.00 $ 2
Arts 473.00 $ 1
Olympia Gladiators 391.00 $ 1
Taxes 297.00 $ 2
Roma Army 397.00 $ 0
Arts 500.00 $ 6
Taxes 4.00 $ 7

The table above shows a simple report, grouped by the "city" value, and with some amount.

The following tables are based on the same code, with the only addition of a table decorator org.displaytag.decorator.TotalTableDecorator .

The decorator will generate totals for any column with the total attribute set, and subtotal rows by grouping using the column with a group attribute set to 1.


Group by city, total for amount and count

City Project Amount Count
Carthago Army 661.00 $ 1
Taxes 242.00 $ 0
Taxes 714.00 $ 4
Carthago subtotal1617.00 $5
Neapolis Army 540.00 $ 2
Arts 473.00 $ 1
Neapolis subtotal1013.00 $3
Olympia Gladiators 391.00 $ 1
Taxes 297.00 $ 2
Olympia subtotal688.00 $3
Roma Army 397.00 $ 0
Arts 500.00 $ 6
Taxes 4.00 $ 7
Roma subtotal901.00 $13
Total4219.00 $24

Group by project and city, totals for amount only, customize labels.

Project City Amount Count
Army Roma 397.00 $ 0
Neapolis 540.00 $ 2
Carthago 661.00 $ 1
partial amount1598.00 $
Arts Neapolis 473.00 $ 1
Roma 500.00 $ 6
partial amount973.00 $
Gladiators Olympia 391.00 $ 1
partial amount391.00 $
Taxes Roma 4.00 $ 7
Carthago 242.00 $ 0
Olympia 297.00 $ 2
Carthago 714.00 $ 4
partial amount1257.00 $
full total4219.00 $

Totals for amount and count, without groups.

City Project Amount Count
Carthago Army 661.00 $ 1
Carthago Taxes 242.00 $ 0
Carthago Taxes 714.00 $ 4
Neapolis Army 540.00 $ 2
Neapolis Arts 473.00 $ 1
Olympia Gladiators 391.00 $ 1
Olympia Taxes 297.00 $ 2
Roma Army 397.00 $ 0
Roma Arts 500.00 $ 6
Roma Taxes 4.00 $ 7
4219.00 $24

If you need subtotals for subgroups, try the MultilevelTotalTableDecorator. Items with only one entry are not totaled separately, but items that occur more than once are subtotaled together.

City Project Amount Count
Carthago
Army
$661.00 1
Taxes
$242.00 0
$714.00 4
Taxes Subtotal $956.00 4
Carthago Subtotal $1617.00 5
Neapolis
Army
$540.00 2
Arts
$473.00 1
Neapolis Subtotal $1013.00 3
Olympia
Gladiators
$391.00 1
Taxes
$297.00 2
Olympia Subtotal $688.00 3
Roma
Army
$397.00 0
Arts
$500.00 6
Taxes
$4.00 7
Roma Subtotal $901.00 13
Total Across All Categories $4219.00 24