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
Post a Comment