javaspringwicketwicket-8

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


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?


Solution

  • 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].