Exploring Display Tags

Being a J2EE developer you have an edge over others , as you can explore thousands of prebuilt open source components over internet . Display Tag is one cool component which i explored recently .

It provides pagination to the JSP page , one just have to set the arraylist of bean object int the request scope of the page and display tags iterate that arraylist and provides a cool tabular view of the data. One just have to mention property names of beans in the dispaly column tag. It uses commons beanutils for iterating the beans.

Now my point in exploring is that i had to provide much more functionalty for my project .

1. Sorting by table headers
2. Exporting to CSV , Excel file .

Both had a simple solution i just had to mention “export=true” in the table header for exporting the table data.

I had to write “sortable=true” in the table column.

Sorting worked out fine with String values but , there was error for date column as it took date as string also. So i had explore more .

What i did, I changed the type of my date field in bean to java.util.Date . The sorting problem was resolved , But the date format caused problem as i had to show it in GMT . For that I downloaded the source code of display tag from sourceforge. There is org.displaytag.sample package in the source . I placed the source of this package in my code and added decorator to the column :

Now it displayed the proper output.

Now with export set to true in table header . It display links to export in CSV,EXCEl,PDF,RTF formats etc. for exporting to be prper ihad to add ‘displaytag.properties’ to the classpath of my application .

export.types=csv excel xml pdf rtf

But it still didn’t work it displayed all the records on the next page.

So what i had to do to sort out the problem was to add a filter fior exporting in the web.xml.

Configure the Filter in your web.xml:


And add mappings for urls the filter will intercept, for example:



Thats it . I made my report table specfic to the client needs.
Thanks Display Tags.

Long Live The open Source Revolution.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s