1

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?

user3552342
  • 657
  • 1
  • 5
  • 14

1 Answers1

4

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

martin-g
  • 17,243
  • 2
  • 23
  • 35
  • Hi @martin-g, that shared article link is related to the Wicket 1.5 implementation which is deprecated in my case. I am looking to implement it in Wicket 8.5 version. Kindly suggest any solution for that? – user3552342 Jan 13 '21 at 09:41
  • The API must be the same in 1.5.x and 8.x for this particular need. Did you try it ? Did you face any issues ?! – martin-g Jan 13 '21 at 11:56
  • Sorry I was missing one step. Now implemented your suggested code and now it is working fine for me. Thanks a lot, martin. – user3552342 Jan 13 '21 at 16:18