Displaytag new features awesome (in theory)
First step was to download and install the displaytag.jar. I also installed the displaytag-export-poi.jar so I could use the new Excel POI support.
Then I had to upgrade our commons-lang, commons-beanutils, and commons-collections jars to the latest versions because of an update of the dependencies for displaytag. No big deal...
Started up my server, and everything looked good so far. My displaytag table showed up and I thought I was good to go.
Then I tried to export... Property not found... In displaytag 1.0 I used a decorator by simply saying decorator="my.MyDecorator" in the display:table tag. But now I get errors on the export because each export doesn't use my default decorator. So now I have to add
<display:setProperty name="export.excel.decorator" value="my.MyDecorator"/>
<display:setProperty name="export.csv.decorator" value="my.MyDecorator"/>
<display:setProperty name="export.pdf.decorator" value="my.MyDecorator"/>
<display:setProperty name="export.xml.decorator" value="my.MyDecorator"/>
to every jsp that I'm using a decorator. I submitted a jira issue to the displaytag team for this.
Now my exports are working, but the caption and footer were still not included, even though the release notes and jira issues say that this is fixed. I tried tweaking a few properties but nothing has worked. Anybody know the answer?
Next I wanted to switch the Excel export to use the new POI support. The one comment in the changelog says to
configure it into your displaytag.properties using 'export.excel.class=org.displaytag.export.ExcelHssfView'
...Oops, I get a message saying that ExcelHssfView is not found. So I explode the jar and see that the package is incorrect. I changed to this
and now my Excel exports look pretty :-)
Lastly I wanted to add the new RTF export feature (which is very vaguely documented, but has a cool demo). Here is what I added to my displaytag.properties:
export.types=csv excel xml pdf rtf
It seems like it starts to go, but then I get an exception during the RTF export. I'm wondering if this deals with my usage of the export filter?
I really love displaytag, and I'd really like these new features to work! Please fill me in, if anyone has gotten these items working. I added comments to the displaytag jira for each of these, and I'll update this post if I hear back from anyone...
[Update 11:27] Thanks to Jorge for responding so quickly on the jira issue for rtf exporting and caption/footer exporting. I'm working with him to see if we can get these two working...
[Update 15:31] I've found some progress on my issue:
For the caption/footer issue:
I had to setup the new export classes for PDF/Excel in my displaytag.properties file like this:
Apparently only these new classes will display the caption/footer? I didn't realize this before...
Secondly, the new classes only work when I remove my Decorator. So I'm going to look into my decorator and see why it fails on the exporting. My decorator works fine for any of the old export classes, but not the new ones that were added for the caption/footer. It throws the previous stack trace with the new export classes for RTF, Excel, and PDF.
For the RTF issue:
My setup from before works for RTF when I don't use my Decorator. There must be something that has changed in the new export classes that is different from the old for Decorator's.
Thanks again to Jorge for helping me out....
[Update March 2: 08:23] After some more trial and error, and a little help from Jorge, I found that the new export classes require your Decorator to implement
org.displaytag.decorator.hssf.DecoratesHssf for Excel and
org.displaytag.render.ItextTableWriter.ItextDecorator for PDF and RTF
I just left the implemented methods blank, since I don't need them. But they need to be there for everything to work...