Displaytag new features awesome (in theory)
I was pumped to upgrade displaytag yesterday from 1.0 to 1.1. We needed the new feature to include the caption and footer in an export, along with some of the other new features that are included in 1.1.
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â/>to every jsp that Iâm using a decorator. I submitted a jira issue to the displaytag team for this.
<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â/>
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
export.excel.class=org.displaytag.export.excel.ExcelHssfViewand 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 rtfIt 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?
export.rtf.class=org.displaytag.export.DefaultRtfExportView
export.rtf=true
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]
[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:
export.pdf.class=org.displaytag.export.DefaultPdfExportViewApparently only these new classes will display the caption/footer? I didnât realize this beforeâŠ
export.excel.class=org.displaytag.export.excel.DefaultHssfExportView
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]
[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 andI just left the implemented methods blank, since I donât need them. But they need to be there for everything to workâŠ
org.displaytag.render.ItextTableWriter.ItextDecorator for PDF and RTF
[/Update]