java - Wicket: AJAXDownload - dowload several files -


i using wicket framework.

i have requirement send client browser several individual files (a zip file not relevant).

i have added page ajaxdownload class extends abstractajaxbehavior - solution sending files client this:

   download = new ajaxdownload(){     @override     protected iresourcestream getresourcestream(){        return new fileresourcestream(file){          @override         public void close() throws ioexception {                     super.close();                     file.delete();         }        };      }};     add(download); 

at other point in code trying initiate download of several files client using ajax request whilst looping through arraylist of files , each time triggering ajaxdownload:

    arraylist<file> labellist = printlabels();      for(int i=0; i<labellist.size(); i++){       file = labellist.get(i);       //initiate download      download.initiate(target);                                                                       } 

however, sending 1 of these files client. have checked , files have been created on server side. 1 of them being sent client.

can give me idea doing wrong?

thanks

you doing correct! don't know how solve problem i'll try explain happens else help:

the ajax response has several entries like: <evaluate>document.location=/some/path/to/a/file</evaluate>

wicket-ajax.js loops on evaluations , executes them. if there 1 entry ok - have file downloaded. if there more browser receives several requests changing location in short time. apparently drops 1 of them.

an obvious solution use callbacks/promises - when download finishes trigger next one. problem there no way how receive notification browser such download finished. or @ least don't know it.

one can roll solution based on timeouts (i.e. settimeout) error prone.

i hope information sufficient else give solution!


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -