Hi Ismael, here is the code for a non-cached download link. (I don't know whether this really solves your problem but just in case.)
final NamesCsvStreamWriter stream = new NamesCsvStreamWriter(); ResourceStreamResource rsr = new ResourceStreamResource(stream) { @Override protected ResourceResponse newResourceResponse(Attributes attributes) { stream.initContent(provider.getFilteredList()); return super.newResourceResponse(attributes); } @Override protected void configureCache(ResourceResponse data, Attributes attributes) { Response response = attributes.getResponse(); ((WebResponse)response).disableCaching(); } }; rsr.setContentDisposition(ContentDisposition.ATTACHMENT); rsr.setTextEncoding(UTF_8); rsr.setFileName("export.csv"); form.add(new ResourceLink<ResourceStreamResource>("export", rsr)); Cheers, Chantal On Mon, 2011-11-14 at 12:39 +0100, Ismael Hasan wrote: > Hello, > > I want to make a DownloadLink for a dynamic resource, a file generated on > the fly; to do this, I overwrite the "onClick" method of DownloadLink so > the file is generated whenever the link is clicked. In the context of my > problem, it should happen that 2 clicks on the link should return different > files without reloading the page. > > The problem I am facing is that the browser caches the link by its "src" > attribute, so the "onClick" method is only called the first time: with the > next clicks the browser directly returns the file generated in the first > "onClick" (and previously downloaded). > > Is there a clean solution to this problem? The solutions I thought so far > are pretty dirty: > > 1.- Instead of having a link, have a list of links, generate a new link > whenever the link is clicked, and refresh the list via Ajax, so instead of > a "dynamic" link there will be a new link each time. > 2.- Add to the link a "foo" parameter each time it is clicked, so the > browser sees it as a different link. I don't know how to do this, any > insight will be appreciated. > > > Thank you for your attention, > > Ismael. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org