Igor,

Don't use the AJAXDownload class. There's another way to do it via Ajax, and
get the Save As dialog.

Click this page:
https://cwiki.apache.org/WICKET/best-practices-and-gotchas.html

Go down to the example that starts with "or do it like this:" (the 2nd
example in the section "Starting download after form submission (Wicket
1.2)")

This example is using the WebResource.

[ WebResource export = new WebResource() { ... etc. ]

Use this WebResource example. Then, add a ResourceLink backed by this
WebResource.

I followed it directly and it works. I get the Save As... dialog box and the
file bytes are constructed at the time the link is clicked.

CODE:
------

// Export to Spreadsheet Link

// 1. Construct a WebResource from Excel bytes
WebResource export = new WebResource() 
{
        @Override
        public IResourceStream getResourceStream() {
                ByteArrayResource bar = new 
ByteArrayResource("application/vnd.ms-excel",
createExcelBytes());
                return bar.getResourceStream();
        }

        @Override
        protected void setHeaders(WebResponse response) {
                super.setHeaders(response);
                response.setAttachmentHeader("report.xls");
        }
};
export.setCacheable(false);

// 2. Add a ResourceLink based on the WebResource
ResourceLink exportLink = new ResourceLink("exportLink", export);       

add(exportLink);
----------------------


--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/AJAXDownload-Example-Doesn-t-Support-Content-Disposition-Save-As-tp3760342p3763726.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

Reply via email to