Re: Initiating File Download through Ajax is not working
Yes it does, it's .fp7 Which is not an extension web server would recognize, could that be the issue? -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Initiating-File-Download-through-Ajax-is-not-working-tp2289784p3072514.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
Re: Initiating File Download through Ajax is not working
Hi It's mostly working for me as well, except that the downloaded file has .html appended to it's name. Any hints? -Val -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Initiating-File-Download-through-Ajax-is-not-working-tp2289784p3071504.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
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