-
New Feature
-
Resolution: Done
-
Normal
-
None
-
Security Level: Jimmy
-
None
-
None
With Content-Disposition header, IE 10 will show up confirm dialog
http://screencast.com/t/Rd3Ki3XoVm
<zk> <window apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('foo.FiledownloadVM')"> <textbox value="@bind(vm.dynamicContent)"/> <button label="download" onClick="@command('download')" /> </window> </zk>
import org.zkoss.bind.annotation.Command; import org.zkoss.cht.system.DownloadFilter; import org.zkoss.util.media.AMedia; import org.zkoss.zk.ui.Executions; import org.zkoss.zk.ui.util.Clients; public class FiledownloadVM { private String dynamicContent = "downloadContent"; @Command public void download() { InputStream is = new ByteArrayInputStream(dynamicContent.getBytes(Charset.forName("utf-8"))); AMedia media = new AMedia("file", "txt", "text/plain", is); String url = Executions.getCurrent().getDesktop().getDownloadMediaURI(media, "report"); Clients.evalJavaScript("window.open('"+url+"')"); } public String getDynamicContent() { return dynamicContent; } public void setDynamicContent(String dynamicContent) { this.dynamicContent = dynamicContent; } }