Hello In the AJAXDownload class, the appended javascript "window.location.href..." will make the browser display a warning on top to prevent file download. If I select the warning then try to download the file, it doesn't work, the file download dialog never popup. The second time I trigger the download it works.
Anybody knowns a way to avoid browser warning without modifying browser options? Or is there another way to initiate file download through ajax? Thanks Jonathan Jonathan Proulx, Programmer Analyst / bluberi gaming technologies inc. Drummondville, Quebec Canada 819.475.5155 (telephone) 819.475.5156 (fax) bluberi.com -------------------------------------------------------------------------- This e-mail and any attachments transmitted with it are personal, privileged and confidential and solely for the use of the individual to whom they are addressed and intended. If you have received this e-mail in error, please notify the sender by return e-mail. If you are not the intended recipient or if you believe that you are not, you are hereby notified that the dissemination, distribution, plagiarism or copying of this e-mail and attachments transmitted with it is strictly prohibited. Ce courriel et les pièces jointes s’y rattachant sont de nature personnelle, privilégiée et confidentielle et pour l’usage exclusif du destinataire à qui ils sont adressés et destinés. Si vous avez reçu ce courriel par erreur, veuillez s’il vous plaît le renvoyer à l’expéditeur. Si vous n’êtes pas le bon destinataire ou si vous croyez ne pas l’être, nous vous informons immédiatement que la publication, distribution, diffusion, copie ou plagiat de ce courriel et de ses pièces jointes sont strictement interdits. -------------------------------------------------------------------------- -----Message d'origine----- De : val360 [mailto:val_wic...@360works.com] Envoyé : 3 décembre 2010 16:42 À : users@wicket.apache.org Objet : Re: Initiating File Download through Ajax is not working final AJAXDownload download = new AJAXDownload() { @Override protected IResourceStream getResourceStream() { return new FileResourceStream(theDatabase.getFile()); } @Override protected String getFileName() { return theDatabase.getFile().getAbsoluteFile().getName(); //FIX!!! the filename gets .html appended to it. } }; add(download); add( new AjaxLink("download") { public void onClick( AjaxRequestTarget target ) { if( theDatabase.isOpen() ) { target.appendJavascript( "alert('The database is open, close or pause the db first.');" ); } else { download.initiate( target ); } } }); And this class is unchanged: import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.behavior.AbstractAjaxBehavior; import org.apache.wicket.request.target.resource.ResourceStreamRequestTarget; import org.apache.wicket.util.resource.IResourceStream; /** * @author Sven Meier * @author Ernesto Reinaldo Barreiro (reier...@gmail.com) */ public abstract class AJAXDownload extends AbstractAjaxBehavior { /** * Call this method to initiate the download. */ public void initiate(AjaxRequestTarget target) { CharSequence url = getCallbackUrl(); target.appendJavascript("window.location.href='" + url + "'"); } public void onRequest() { getComponent().getRequestCycle().setRequestTarget( new ResourceStreamRequestTarget(getResourceStream(), getFileName())); } /** * @see ResourceStreamRequestTarget#getFileName() */ protected String getFileName() { return null; } /** * Hook method providing the actual resource stream. */ protected abstract IResourceStream getResourceStream(); } -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Initiating-File-Download-through-Ajax-is-not-working-tp2289784p3071816.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 --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org