Thanks Sean and Igor, based on both your responses I've
come up with roughly the following which is working:
final
String filename =
"thefile.csv";
final String contentType = "text/csv"; final String content = "the,content,is,this"; add(new Link("link"){ public void onClick(){ RequestCycle.get().setRequestTarget(EmptyRequestTarget.getInstance()); WebResponse response = (WebResponse) getResponse(); response.setContentType(contentType); response.setAttachmentHeader(filename); response.setHeader("Cache-Control", "max-age=0"); OutputStream out = response.getOutputStream(); try { out.write(content.getBytes()); out.flush(); } catch (IOException ex) { // ignore }
} }); From: Sean Sullivan [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 11, 2006 11:16 AM To: Levy, Jeremy Subject: Re: [Wicket-user] Downloading a file generated on the fly Here's an application that I wrote. The application retrieves data from a database and converts it to an Excel XLS file. I am sending the XLS file to the web browser via the ServletOutputStream. Note: DatabaseQueryForm extends BaseForm http://svn.sourceforge.net/viewcvs.cgi/oscon2006/oscon2006/src/java/oscon2006/web/DatabaseQueryForm.java?view=markup&rev=91 http://svn.sourceforge.net/viewcvs.cgi/oscon2006/oscon2006/src/java/oscon2006/web/BaseForm.java?view=markup&rev=60 Levy, Jeremy wrote:
Important Notice to Recipients:
It is important that you do not use e-mail to request, authorize or effect the purchase or sale of any security or commodity, to send fund transfer instructions, or to effect any other transactions. Any such request, orders, or instructions that you send will not be accepted and will not be processed by Morgan Stanley.
|
------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user