Hi Sebastien,
AjaxDownload uses IResource and ResourceReference as ResourceLink does
it - IMO these are the most general abstractions for resources in Wicket.
If you prefer to work with an IResourceStream, you can pass a
ResourceStreamResource to AjaxDownload's constructor:
new AjaxDownload(new ResourceStreamResource() {
{
setFileName("myfilename");
setContentDisposition(ContentDisposition.ATTACHMENT);
}
protected IResourceStream getResourceStream(Attributes attributes) {
return new DataExporterResourceStreamWriter(new
CSVDataExporter(), provider, columns);
}
});
With this lazy creation of the stream, it is not necessary to hold it in
the component tree.
Have fun
Sven
On 01.04.2017 16:56, Sebastien wrote:
Hi devs,
I was wondering if would be possible to change the AjaxDownload a bit so it
works with IRequestHandler or IResourceStream.
Maybe something like this:
AjaxDownload download = new AjaxDownload();
(...)
IResourceStream stream = new DataExporterResourceStreamWriter(new
CSVDataExporter(), provider, columns);
download.initiate(target, stream, "myfilename")
or
IResourceStream stream = new DataExporterResourceStreamWriter(new
CSVDataExporter(), provider, columns);
IRequestHandler handler = new ResourceStreamRequestHandler(stream,
filename));
download.initiate(target, handler)
Thanks in advance & best regards,
Sebastien.