View source
City Project Amount Count
Carthago Gladiators 113.00 $ 9
Neapolis Army 182.00 $ 7
Gladiators 234.00 $ 8
Olympia Army 192.00 $ 7
Army 198.00 $ 4
Arts 93.00 $ 9
Gladiators 167.00 $ 0
Gladiators 521.00 $ 0
Gladiators 628.00 $ 5
Gladiators 907.00 $ 0

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 Gladiators 113.00 $ 9
Carthago subtotal113.00 $9
Neapolis Army 182.00 $ 7
Gladiators 234.00 $ 8
Neapolis subtotal416.00 $15
Olympia Army 192.00 $ 7
Army 198.00 $ 4
Arts 93.00 $ 9
Gladiators 167.00 $ 0
Gladiators 521.00 $ 0
Gladiators 628.00 $ 5
Gladiators 907.00 $ 0
Olympia subtotal2706.00 $25
Total3235.00 $49

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

Project City Amount Count
Army Neapolis 182.00 $ 7
Olympia 192.00 $ 7
198.00 $ 4
partial amount572.00 $
Arts Olympia 93.00 $ 9
partial amount93.00 $
Gladiators Carthago 113.00 $ 9
Olympia 167.00 $ 0
Neapolis 234.00 $ 8
Olympia 521.00 $ 0
628.00 $ 5
907.00 $ 0
partial amount2570.00 $
full total3235.00 $

Totals for amount and count, without groups.

City Project Amount Count
Carthago Gladiators 113.00 $ 9
Neapolis Army 182.00 $ 7
Neapolis Gladiators 234.00 $ 8
Olympia Army 192.00 $ 7
Olympia Army 198.00 $ 4
Olympia Arts 93.00 $ 9
Olympia Gladiators 167.00 $ 0
Olympia Gladiators 521.00 $ 0
Olympia Gladiators 628.00 $ 5
Olympia Gladiators 907.00 $ 0
3235.00 $49

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
Gladiators
$113.00 9
Neapolis
Army
$182.00 7
Gladiators
$234.00 8
Neapolis Subtotal $416.00 15
Olympia
Army
$192.00 7
$198.00 4
Army Subtotal $390.00 11
Arts
$93.00 9
Gladiators
$167.00 0
$521.00 0
$628.00 5
$907.00 0
Gladiators Subtotal $2223.00 5
Olympia Subtotal $2706.00 25
Total Across All Categories $3235.00 49