Thursday October 02, 2003
Simple "workaround" for exporting with the displaytag using Tiles
I figured out an easy "workaround" to the fact that the displaytag's export feature (to XML, CSV, and Excel) doesn't work when using Tiles. The happens because the response has already been committed by Tiles (when including previous JSPs) and the displaytag is unable to set the contentType. Here's my workaround:
In struts-config.xml, create a local forward that goes directly to the JSP:
<forward name="exportList" path="/WEB-INF/pages/userList.jsp"/>
Then in your Action, add a little logic to see if you should forward to the definition or to the list:
// if exportType is a parameter, forward directly to JSP
if (request.getParameter("exportType") != null) {
if (log.isDebugEnabled()) {
log.debug("export detected, forwarding directly to list jsp");
}
return mapping.findForward("exportList");
} else {
// return a forward to the user list definition
return mapping.findForward("list");
}
Tested with displaytag 0.8.5 on Windows XP and Tomcat 4.1.27. Enjoy!
Update: This workaround will not work with displaytag 1.0b1. There is another solution using a Filter, so we'll try to incorporate that into the 1.0 release.
Posted in Java
at Oct 02 2003, 09:58:41 PM MDT
1 Comment
Search This Site
Recent Entries
- Secure JSON Services with Play Scala and SecureSocial
- My What's New in Spring 3.1 Presentation
- Twitter's Open Source Summit: Bootstrap 2.0 Edition
- Refreshing AppFuse's UI with Twitter Bootstrap
- 2011 - A Year in Review
- Upgrading AppFuse to Spring Security 3.1 and Spring 3.1
- What have I been working on at Taleo?
- Our Engaging Trip to Paris and Antwerp
- My HTML5 with Play Scala, CoffeeScript and Jade Presentation from Devoxx 2011
- Deploying Java and Play Framework Apps to the Cloud with James Ward
Posted by Nic Werner on November 21, 2003 at 01:32 PM MST #