View source
City Project Amount Count
Carthago Taxes 467.00 $ 4
Neapolis Army 264.00 $ 9
Army 404.00 $ 8
Army 926.00 $ 9
Gladiators 687.00 $ 0
Olympia Taxes 408.00 $ 8
Roma Army 678.00 $ 6
Army 838.00 $ 7
Arts 525.00 $ 6
Taxes 256.00 $ 1

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 Taxes 467.00 $ 4
Carthago subtotal467.00 $4
Neapolis Army 264.00 $ 9
Army 404.00 $ 8
Army 926.00 $ 9
Gladiators 687.00 $ 0
Neapolis subtotal2281.00 $26
Olympia Taxes 408.00 $ 8
Olympia subtotal408.00 $8
Roma Army 678.00 $ 6
Army 838.00 $ 7
Arts 525.00 $ 6
Taxes 256.00 $ 1
Roma subtotal2297.00 $20
Total5453.00 $58

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

Project City Amount Count
Army Neapolis 264.00 $ 9
404.00 $ 8
Roma 678.00 $ 6
838.00 $ 7
Neapolis 926.00 $ 9
partial amount3110.00 $
Arts Roma 525.00 $ 6
partial amount525.00 $
Gladiators Neapolis 687.00 $ 0
partial amount687.00 $
Taxes Roma 256.00 $ 1
Olympia 408.00 $ 8
Carthago 467.00 $ 4
partial amount1131.00 $
full total5453.00 $

Totals for amount and count, without groups.

City Project Amount Count
Carthago Taxes 467.00 $ 4
Neapolis Army 264.00 $ 9
Neapolis Army 404.00 $ 8
Neapolis Army 926.00 $ 9
Neapolis Gladiators 687.00 $ 0
Olympia Taxes 408.00 $ 8
Roma Army 678.00 $ 6
Roma Army 838.00 $ 7
Roma Arts 525.00 $ 6
Roma Taxes 256.00 $ 1
5453.00 $58

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
Taxes
$467.00 4
Neapolis
Army
$264.00 9
$404.00 8
$926.00 9
Army Subtotal $1594.00 26
Gladiators
$687.00 0
Neapolis Subtotal $2281.00 26
Olympia
Taxes
$408.00 8
Roma
Army
$678.00 6
$838.00 7
Army Subtotal $1516.00 13
Arts
$525.00 6
Taxes
$256.00 1
Roma Subtotal $2297.00 20
Total Across All Categories $5453.00 58