I followed the AJAXDownload example on how to do an Ajax-based file download:
https://cwiki.apache.org/WICKET/ajax-update-and-file-download-in-one-blow.html It works, but my problem is, I can't get it to support the Content-Disposition header "attachment" to do the Save As dialog box. The file opens *immediately* inside the browser even when I override setHeader(..) for the ByteArrayResource. This works with the regular ResourceLink, but not this AJAXDownload. Can anyone help how to do this AJAX-based download, but with the Save As Content-Disposition=attachment, so it gives me a prompt before I download? CODE: final AJAXDownload download = new AJAXDownload() { @Override protected IResourceStream getResourceStream() { // TODO Auto-generated method stub ByteArrayResource bar = new ByteArrayResource("application/vnd.ms-excel", createExcelBytes()); { @Override protected void setHeaders(WebResponse response) { response.setHeader("Content-Disposition", "attachment; filename=report.xls"); } }; return bar.getResourceStream(); } }; add(download); AjaxLink exportLink = new AjaxLink("exportLink") { @Override public void onClick(AjaxRequestTarget target) { download.initiate(target); } }; AJAXDownload (from example): ----------------------------- public abstract class AJAXDownload extends AbstractAjaxBehavior { /** * Call this method to initiate the download. */ public void initiate(AjaxRequestTarget target) { CharSequence url = getCallbackUrl(); target.appendJavascript("window.location.href='" + url + "'"); } public void onRequest() { getComponent().getRequestCycle().setRequestTarget( new ResourceStreamRequestTarget(getResourceStream(), getFileName())); } /** * @see ResourceStreamRequestTarget#getFileName() */ protected String getFileName() { return null; } /** * Hook method providing the actual resource stream. */ protected abstract IResourceStream getResourceStream(); } -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/AJAXDownload-Example-Doesn-t-Support-Content-Disposition-Save-As-tp3760342p3760342.html Sent from the Users forum mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org