I have a Wicket application which allows the user to generate PDFs and open them in a popup. I defined my own shared resource like this
public class PdfResourceReference extends SharedResourceReference {
@Override
public IResource getResource() {
return new ByteArrayResource("application/pdf") {
@Override
protected byte[] getData(final Attributes attributes) {
// generate the pdf and return byte[]
}
};
}
}
In the application class I mount it via
mountResource("reportPdf", new PdfResourceReference());
It all works fine and the browser opens the pdf. The problem though is that the name of the pdf file (once the user tries to save it) is always "reportPdf". Our users want the pdf to be named according to the report type or the customer number. Something like "0123someCustomerId_report.pdf"
I've found a similar stackoverflow question which suggest using the "Content-disposition" header. Unfortunately I couldn't figure out how to get it working (it also seems to not be supported by all browsers).
Are there other solutions to this kind of problem? Is it possible to use a mount path with a dynamic (regex like) path?