Take a look at ZipResourceStream
. With this class, you can generate zip-content of the directory on the fly and use org.apache.wicket.markup.html.link.ResourceLink
with ResourceStreamResource
to reference it.
File file = new File(path); IResourceStream resStream = new ZipResourceStream(file); ResourceStreamResource resource = new ResourceStreamResource(resStream); ResourceLink link = new ResourceLink("link", resource); add(link);
Alternatively, if you prefer to archive the file with another tool, you can use DownloadLink
:
File zipFile = generateZipFile(); IModel fileModel = new Model(zipFile); add(new DownloadLink("dllink", fileModel);
If you prefer to generate the file on the fly in Link onClick, take a look at this question: How to use Wicket DownloadLink with a file created on the fly?
source share