Uncommented Bytes

Wednesday, March 01, 2006

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"/>
<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
export.excel.class=org.displaytag.export.excel.ExcelHssfView

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
export.rtf.class=org.displaytag.export.DefaultRtfExportView
export.rtf=true

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]

[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.DefaultPdfExportView
export.excel.class=org.displaytag.export.excel.DefaultHssfExportView

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]

[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...
[/Update]

16 Comments:

  • Hello,

    You didn't tell on which portals you tried DisplayTag 1.1. It appears that exporting (use an Servlet Export Filter) is not quite well supported, for example, on WebSphere Portal Server 5.1..

    Tom

    By Anonymous Tom, at 14 March, 2006 04:50  

  • I was just using it on Weblogic 8.1 in this case, so there was no portal server involved.

    I have used DisplayTag 1.0 on the Apache Jetspeed portal successfully in the past, but that was a year or so ago...

    By Blogger Jeff Sheets, at 14 March, 2006 07:52  

  • Hi Jeff,
    I recently migrated to DisplayTag
    1.1, I am using
    displaytag-portlet-1.1.jar
    displaytag-export-poi-1.1.jar
    poi-2.5.1.jar and othe common jars mentioned in your post. I also made change in displaytag.properties to include class for excel and pdf export:

    export.pdf.class=org.displaytag.export.DefaultPdfExportView
    export.excel.class=org.displaytag.
    export.excel.DefaultHssfExportView

    After this when I try to pull Excel
    report I am getting this exception:

    javax.servlet.ServletException: org.apache.poi.hssf.usermodel.HSSFDataFormat.getBuiltinFormat(Ljava/lang/String;)S
    at org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
    at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
    at org.apache.jsp.agent.merchanttracking.AgentMerchantList_jsp._jspService(AgentMerchantList_jsp.java:199)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


    It will be really great of you if you can put some light on this....
    Thanks and Regards
    Vikram

    By Anonymous vikram, at 23 June, 2006 06:37  

  • vikram,

    Are you using a Decorator class? If so, 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

    By Blogger Jeff Sheets, at 23 June, 2006 08:25  

  • Thanks! I was trying to figure out why pdf wasn't showing a caption. Thanks for blogging about it

    By Anonymous Chris Blackburn, at 10 November, 2006 15:40  

  • Hi folks,
    I am using displytag1.1 in my Portal applciation.However whn i use decorator class say Table decorator with fully classified name it says noclassfund excepton.I have checked tht display1.1 jar is present in my classpath.still whtas the prob can ne1 help me.
    Thanks
    Jatin Jain

    By Anonymous Anonymous, at 26 November, 2006 02:32  

  • do you know how to display the Export Options at the top of the table instead of at the bottom as a footer.

    Thanks

    By Anonymous Anonymous, at 23 April, 2007 16:03  

  • Off the top of my head, I think you should try css. But I don't remember the real answer. Sorry!

    By Blogger Jeff Sheets, at 09 May, 2007 21:36  

  • Thank you - the tip to do a setproperty on the export with decorator really helped to get my exports working with the decorator.

    By Anonymous Anonymous, at 14 May, 2007 18:53  

  • I am get the following error websphere portal 5.1 despite having the filter in web.xml.
    I am trying to use the excel export option and it failing with Nested Exception below.

    my settings in
    display.properties:
    export.excel.class=org.displaytag.export.excel.ExcelHssfView
    web.xml:
    using responseoveridefilter

    Nseted Exception:
    Unable to reset response before returning exported data. You are not using an export filter. Be sure that no other jsp tags are used before display:table or refer to the displaytag documentation on how to configure the export filter (requires j2ee 1.3).

    please help me with this and let me know if export excel is possible with wesphere portal?

    By Anonymous Anonymous, at 25 October, 2007 15:04  

  • This comment has been removed by the author.

    By Blogger rohit, at 13 March, 2010 16:21  

  • hii tere,i hav problem with rtf export,
    i get the export working but it is exportin only one page not the whole list.
    i have updated the displaytag.properties file , so tht it exports the whole list but no profit.
    The other exports(csv,xml,pdf,excel) are exporting whole list. so please help me to solve my problem.
    i m using displaytag1.2 jar
    thanx in advance

    By Blogger rohit, at 13 March, 2010 16:25  

  • hey ,
    Im using Displaytags but my exports are not carrying any data.For example when I open the exported excel sheet I get an alert saying "File Error :Data may have been lost"

    By Anonymous scr, at 16 June, 2010 01:51  

  • I'm having the same problem while exporting. Only exports the paginated list. The bug is registered at http://jira.codehaus.org/browse/DISPL-292 but how can i have a solution without compiling a new jar?. Any ideas?. Thanks.

    By Blogger Tato, at 11 June, 2011 22:33  

  • I used displaytag 1.2 and integrating with my liferay portlet application. All things runs well except exporting.

    When i try to export it gives me error.

    like

    Unable to set Response....

    Please Help me

    By Blogger Pradip Bhatt, at 28 June, 2013 05:32  

  • Pradip,

    Have you set up the export filter in web.xml? Give that a shot

    -- Jeff

    By Blogger Jeff Sheets, at 28 June, 2013 06:38  

Post a Comment

Links to this post:

Create a Link

<< Home