On Mon, Mar 30, 2015 at 7:32 PM, ChambreNoire <a...@tentelemed.com> wrote:

> I was using the AjaxDownload outlined in
>
> https://cwiki.apache.org/confluence/display/WICKET/AJAX+update+and+file+download+in+one+blow
> before with the same problem.
>
> I switched to DownloadLink :
>
> IModel<File> model = new LoadableDetachableModel<File>() {
>
>     @Override
>     protected File load() {
>
>         File path;
>         try {
>             path = new ClassPathResource("descriptors/hc").getFile();
>

'hc' has no extension. Neither the server, nor the browser will have idea
how to present it. So I think it is expected that the browser downloads it
instead of showing it in a tab/window.


>         } catch (IOException exception) {
>             return null;
>         }
>         return new File(path, item.getModelObject().getFile());
>     }
> };
>
> add(new DownloadLink(ID_ALARM, model) {
>
>     @Override
>     protected void onComponentTag(ComponentTag tag) {
>         super.onComponentTag(tag);
>
>         tag.getAttributes().put("target", "_blank");
>     }
> });
>
> Now the file downloads rather than opening in a new tab and it's still
> blank
> with the correct number of pages...
>

"correct number of pages"
I'd say the correct file is delivered. It is your viewer that doesn't
represent it correctly.
Check the sizes of the original file and the downloaded one.
I guess the file is binary so also try with 'cmp' (Linux command line) or
something similar.


>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Download-serves-empty-files-with-correct-number-of-pages-tp4670117p4670123.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