Wicket: Submit button to download binary file -


i know how create plain link download arbitrary binary data (using resourcelink resourcestreamresource , abstractresourcestream), want create form submit button should either redirect form again (e.g. correct input error) or download arbitrary binary data file without going different page. how can achieved?

for binary part, try this:

final resourcestreamrequesthandler target = new resourcestreamrequesthandler(new abstractresourcestream() {     @override     public string getcontenttype() {         return "application/octet-stream";     }      @override     public inputstream getinputstream() throws resourcestreamnotfoundexception {         return new bytearrayinputstream(yourbinarycontent);     }      @override     public void close() throws ioexception {     } }); target.setfilename("response.dat"); target.setcontentdisposition(contentdisposition.attachment);  getrequestcycle().schedulerequesthandleraftercurrent(target); 

otherwise, handle 'text' responses, use code have.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

spring cloud - How to configure SpringCloud Eureka instance to point to https on non standard port -

javascript - Bootstrap Popover: iOS Safari strange behaviour -