It should be the AJAX part that fails for some reason... If you put a break point on writeDownload you might see that no "download" request is produced. The trick work as follows. Please, try to provide a quick start or provide more info because I do not see how we could otherwise help you.
On Tue, Jun 18, 2013 at 3:14 PM, René Hartwig < [email protected]> wrote: > Hi, > > I'm using Wicket 6.7.0 with an embedded Jetty and implemented a file > download mechanism as suggested here: > > https://cwiki.apache.org/confluence/display/WICKET/AJAX+update+and+file+download+in+one+blow > > My implementation is slighlty different from the suggested one, but still > I think it is pretty much the same: > private void writeDownload(final List<TransferModel> transfers) { > String fileName = UrlEncoder.QUERY_INSTANCE.encode("logExport-" + > CalendarTool.format(beginDate) + "-" + CalendarTool.format(endDate) > + ".csv", getRequest().getCharset()); > IResourceStream resourceStream = new > AbstractResourceStreamWriter() { > > @Override > public void write(OutputStream output) throws IOException { > BHLogExport.writeCSVLog(transfers, output, getLocalizer(), > Session.get().getLocale(), LogExportPanel.this); > } > > @Override > public String getContentType() { > return "text/csv"; > } > }; > ResourceStreamRequestHandler resource = new > ResourceStreamRequestHandler(resourceStream, fileName); > resource.setContentDisposition(ContentDisposition.ATTACHMENT); > resource.setCacheDuration(Duration.NONE); > // resource.setFileName(fileName); > getRequestCycle().scheduleRequestHandlerAfterCurrent(resource); > try { > resourceStream.close(); > } catch (IOException e) { > throw new CryptshareRuntimeException("An error occured while > trying to write the csv file to the output stream.", e); > } > } > > I am using a custom Button wrapping an AjaxButton. Except from that, there > is no difference, but I still keep getting an error message instead of > the file download dialog. > Do you have any suggestions what I might be doing wrong? > > Thanks and best regards, > René Hartwig > -- > > René Hartwig > Senior Developer > > *Befine Solutions AG - The Cryptshare Company* > Bebelstraße 17 > 79108 Freiburg > Germany > > Tel: +49 (0) 761 38913 0 > Fax: +49 (0) 761 38913 115 > > E-Mail: *[email protected]* > Internet: http://www.cryptshare.com > > ========================================================================= > > Your attachments are too large or too confidential for e-mail? > Get to know Cryptshare! > > http://www.cryptshare.com > > ========================================================================= > > > <http://www.facebook.com/cryptshare><http://www.linkedin.com/company/befine-solutions/products> > > Amtsgericht Freiburg HRB 6144 > Vorstand Mark Forrest, Dominik Lehr > Aufsichtsratsvorsitzender Edgar Fehrenbacher > > > > -- Regards - Ernesto Reinaldo Barreiro
