View source
A Caption
CITY PROJECT HOURS TASK
Sample footer
Carthago Army 158.0 magna erat accusam et
  
 
  Carthago Total: 158.0  
 
Neapolis Army 179.0 voluptua consetetur sea duo
  
 
  Neapolis Total: 179.0  
 
Olympia Army 609.0 labore takimata sed dolor
  
 
  Olympia Total: 609.0  
 
Carthago Army 712.0 takimata sea amet invidunt
Arts 260.0 clita dolore tempor est
  
 
  Carthago Total: 972.0  
 
Neapolis Arts 420.0 tempor dolores sanctus eirmod
  
 
  Neapolis Total: 420.0  
 
Roma Gladiators 706.0 sea tempor sanctus justo
Taxes 36.0 ipsum no diam diam
440.0 et magna Lorem ipsum
  
 
  Roma Total: 1182.0  
 
Carthago Taxes 754.0 justo tempor sit est
  
 
  Carthago Total: 754.0  
 

 Grand Total:4274.0 

The purpose of this example is two-fold:

  1. to demonstrate exports that mimic the HTML data presentation. What you see rendered in the Excel, PDF, and RTF formats is what you see rendered as HTML
  2. to demonstrate how easy it is to implement this by applying the template method pattern to render the main table and decorate it

Why would one want to do this? When typical business users are presented with the displaytag export facility, they usually expect the exported Excel or PDF to look just like the HTML in their browser; they expect a WYSIWYG rendering. Yes, even when exporting to Excel, users tend to expect the same look, feel, and structure of the rendered HTML, instead of raw data.

( Note : the model state in this example changes with every view request, such that the data shown will change with every request, but the report's structure remains the same in all formats.)

What this table shows: You have a List who's objects are sorted and grouped by column A, column B and column C, so instead of repeating columns A, B over and over again, it does a grouping of those columns, and only shows data in those columns when it changes. Think of reports... We use the this display tag as a key part of our reporting framework.

Grouping is straight-forward, simply make sure that your list that you are providing is sorted appropriately, then indicate the grouping order via the group attribute of the column tags.