Wicket 8.x Excel download link not working and showing 404 error

294 Views Asked by At

I have upgraded Wicket 1.x to wicket 8.x. After this upgrade Excel and PDF download stop working and showing 404 error.

I have found this below class has been removed after the wicket 1.5 version.

      org.apache.wicket.markup.html.DynamicWebResource

And this below class is the replacement of this class

      org.apache.wicket.request.resource.ByteArrayResource

Are there any tutorials or demo on how to do this in Wicket 8.x version?

1

There are 1 best solutions below

3
On BEST ANSWER

The usage is something like this:

ResourceReference ref = new ResourceReference() {
  @Override
  public IResource getResource() {
     byte[] theExcelFileAsBytes = ...;
     return new  new ByteArrayResource("application/msexcel", theExcelFileAsBytes, "fileName.xsl");
  }
};

ResourceLink<Void> link = new ResourceLink<>("linkId", ref);
parent.add(link);

Here is an article about mounting resources at specific paths. You can use ExternalLink to link to such resource[reference].