Re: Send file to client via Ajax
Perfect! The label was just used to have something to repaint and show AJAX was working! The whole thing was intended to provide an example of how to do something and not the "complete means" to achieve it. If you feel that will make the example more clear feel free to edit the Wiki page and add/change any information in there! Best, Ernesto On Tue, Oct 6, 2009 at 1:35 PM, Giambalvo, Christian < christian.giamba...@excelsisnet.com> wrote: > By the way, i changed it a bit and now i repaint the link instead of > repainting the label, so the label isn't needed. > >private final DocumentResourceListener documentResourceListener; > >private final MyPdfResource pdf; > >.. > final AjaxFallbackLink link = new AjaxFallbackLink(componentId) >{ >private static final long serialVersionUID = > 8947164550163497764L; > >@Override >public void onClick(final AjaxRequestTarget target) { >if (target != null) { >target.addComponent(this); >} >final BillItem item = (BillItem) model.getObject(); > >try { >pdf.setAttachmentname(item.getBillNumber() + > ".pdf"); >pdf.setContent(PdfHelper.generatePdf(item)); >final String url = > BillDataviewPanel.this.documentResourceListener.getURL().toString(); >target.appendJavascript("window.location.href='" > + url + "';"); >} catch (final Exception e) { >Logger.error(e); >} > >} >}; >.. > >this.documentResourceListener = new > DocumentResourceListener("listener", this.pdf); >this.add(this.documentResourceListener); > > And i changed MyPdfResource tob e more flexible; > > public class MyPdfResource extends DynamicWebResource { > > private byte[] content = null; > >private String attachmentname = null; > >public String getAttachmentname() { >return this.attachmentname; > } > >@Override >protected ResourceState getResourceState() { >return new ResourceState() { >@Override >public String getContentType() { >return "application/pdf"; >} > >@Override >public byte[] getData() { >try { > return MyPdfResource.this.content; >} catch (final Exception e) { >return null; >} >} >}; >} > >public void setAttachmentname(final String name) { >this.attachmentname = name; >} > >public void setContent(final byte[] content) { >this.content = content; >} > >@Override >protected void setHeaders(final WebResponse response) { >super.setHeaders(response); >response.setAttachmentHeader(this.attachmentname); > } > } > > Mit freundlichen Grüßen > Christian Giambalvo > -- > Fachinformatiker für Anwendungsentwicklung > > EXCELSIS Informationssysteme GmbH > Wilhelmsplatz 8 - 70182 Stuttgart > Mobile +49 176 196 32 406 > Office +49 711 6 20 30 406 > christian.giamba...@excelsisnet.com > www.excelsisnet.com > www.twitter.com/excelsis_info > > Sitz Stuttgart > Amtsgericht Stuttgart, HRB 21104 > Geschäftsführer: Christian Sauter, Dr. Nils Herda, Frank Wolf > > > -Ursprüngliche Nachricht- > Von: Ernesto Reinaldo Barreiro [mailto:reier...@gmail.com] > Gesendet: Dienstag, 6. Oktober 2009 13:18 > An: users@wicket.apache.org > Betreff: Re: Send file to client via Ajax > > Done! > > http://cwiki.apache.org/confluence/display/WICKET/AJAX+update+and+file+download+in+one+blow > > < > http://cwiki.apache.org/confluence/display/WICKET/AJAX+update+and+file+download+in+one+blow > > > Ernesto > > On Tue, Oct 6, 2009 at 12:15 PM, Giambalvo, Christian < > christian.giamba...@excelsisnet.com> wrote: > > > Yes, please add it. > > > > Mit freundlichen Grüßen > > Christian Giambalvo > > -- > > Fachinformatiker für Anwendungsentwicklung > > > > EXCELSIS Informationssysteme GmbH > > Wilhelmsplatz 8 - 70182 Stuttgart > > Mobile +49 176 196 32 406 > > Office +49 711 6 20 30 406 > > christian.giamba...@e
AW: Send file to client via Ajax
By the way, i changed it a bit and now i repaint the link instead of repainting the label, so the label isn't needed. private final DocumentResourceListener documentResourceListener; private final MyPdfResource pdf; .. final AjaxFallbackLink link = new AjaxFallbackLink(componentId) { private static final long serialVersionUID = 8947164550163497764L; @Override public void onClick(final AjaxRequestTarget target) { if (target != null) { target.addComponent(this); } final BillItem item = (BillItem) model.getObject(); try { pdf.setAttachmentname(item.getBillNumber() + ".pdf"); pdf.setContent(PdfHelper.generatePdf(item)); final String url = BillDataviewPanel.this.documentResourceListener.getURL().toString(); target.appendJavascript("window.location.href='" + url + "';"); } catch (final Exception e) { Logger.error(e); } } }; .. this.documentResourceListener = new DocumentResourceListener("listener", this.pdf); this.add(this.documentResourceListener); And i changed MyPdfResource tob e more flexible; public class MyPdfResource extends DynamicWebResource { private byte[] content = null; private String attachmentname = null; public String getAttachmentname() { return this.attachmentname; } @Override protected ResourceState getResourceState() { return new ResourceState() { @Override public String getContentType() { return "application/pdf"; } @Override public byte[] getData() { try { return MyPdfResource.this.content; } catch (final Exception e) { return null; } } }; } public void setAttachmentname(final String name) { this.attachmentname = name; } public void setContent(final byte[] content) { this.content = content; } @Override protected void setHeaders(final WebResponse response) { super.setHeaders(response); response.setAttachmentHeader(this.attachmentname); } } Mit freundlichen Grüßen Christian Giambalvo -- Fachinformatiker für Anwendungsentwicklung EXCELSIS Informationssysteme GmbH Wilhelmsplatz 8 - 70182 Stuttgart Mobile +49 176 196 32 406 Office +49 711 6 20 30 406 christian.giamba...@excelsisnet.com www.excelsisnet.com www.twitter.com/excelsis_info Sitz Stuttgart Amtsgericht Stuttgart, HRB 21104 Geschäftsführer: Christian Sauter, Dr. Nils Herda, Frank Wolf -Ursprüngliche Nachricht- Von: Ernesto Reinaldo Barreiro [mailto:reier...@gmail.com] Gesendet: Dienstag, 6. Oktober 2009 13:18 An: users@wicket.apache.org Betreff: Re: Send file to client via Ajax Done! http://cwiki.apache.org/confluence/display/WICKET/AJAX+update+and+file+download+in+one+blow <http://cwiki.apache.org/confluence/display/WICKET/AJAX+update+and+file+download+in+one+blow> Ernesto On Tue, Oct 6, 2009 at 12:15 PM, Giambalvo, Christian < christian.giamba...@excelsisnet.com> wrote: > Yes, please add it. > > Mit freundlichen Grüßen > Christian Giambalvo > -- > Fachinformatiker für Anwendungsentwicklung > > EXCELSIS Informationssysteme GmbH > Wilhelmsplatz 8 - 70182 Stuttgart > Mobile +49 176 196 32 406 > Office +49 711 6 20 30 406 > christian.giamba...@excelsisnet.com > www.excelsisnet.com > www.twitter.com/excelsis_info > > Sitz Stuttgart > Amtsgericht Stuttgart, HRB 21104 > Geschäftsführer: Christian Sauter, Dr. Nils Herda, Frank Wolf > > > -Ursprüngliche Nachricht- > Von: Ernesto Reinaldo Barreiro [mailto:reier...@gmail.com] > Gesendet: Dienstag, 6. Oktober 2009 11:48 > An: users@wicket.apache.org > Betreff: Re: Send file to client via Ajax > > Nice to hear it was of some help! I have learned a bit too while doing > it:-) > Cheers, > > Ernesto > > P.S. Shall I add this to a Wiki page?... when I find the time;-) > > On Tue, Oct 6, 2009 at 11:39 AM, Giambalvo, Christian < > christian.giamba...@excelsisnet.com> wrote: > > > Works like a charm. > > I think i've learned something about resource download via ajax. > > Thanks for hat. > > > > > > Mit freundlichen Grüßen > > Christian Giambalvo > > -- > > Fachinformatiker für Anwendu
Re: Send file to client via Ajax
Done! http://cwiki.apache.org/confluence/display/WICKET/AJAX+update+and+file+download+in+one+blow <http://cwiki.apache.org/confluence/display/WICKET/AJAX+update+and+file+download+in+one+blow> Ernesto On Tue, Oct 6, 2009 at 12:15 PM, Giambalvo, Christian < christian.giamba...@excelsisnet.com> wrote: > Yes, please add it. > > Mit freundlichen Grüßen > Christian Giambalvo > -- > Fachinformatiker für Anwendungsentwicklung > > EXCELSIS Informationssysteme GmbH > Wilhelmsplatz 8 - 70182 Stuttgart > Mobile +49 176 196 32 406 > Office +49 711 6 20 30 406 > christian.giamba...@excelsisnet.com > www.excelsisnet.com > www.twitter.com/excelsis_info > > Sitz Stuttgart > Amtsgericht Stuttgart, HRB 21104 > Geschäftsführer: Christian Sauter, Dr. Nils Herda, Frank Wolf > > > -Ursprüngliche Nachricht- > Von: Ernesto Reinaldo Barreiro [mailto:reier...@gmail.com] > Gesendet: Dienstag, 6. Oktober 2009 11:48 > An: users@wicket.apache.org > Betreff: Re: Send file to client via Ajax > > Nice to hear it was of some help! I have learned a bit too while doing > it:-) > Cheers, > > Ernesto > > P.S. Shall I add this to a Wiki page?... when I find the time;-) > > On Tue, Oct 6, 2009 at 11:39 AM, Giambalvo, Christian < > christian.giamba...@excelsisnet.com> wrote: > > > Works like a charm. > > I think i've learned something about resource download via ajax. > > Thanks for hat. > > > > > > Mit freundlichen Grüßen > > Christian Giambalvo > > -- > > Fachinformatiker für Anwendungsentwicklung > > > > EXCELSIS Informationssysteme GmbH > > Wilhelmsplatz 8 - 70182 Stuttgart > > Mobile +49 176 196 32 406 > > Office +49 711 6 20 30 406 > > christian.giamba...@excelsisnet.com > > www.excelsisnet.com > > www.twitter.com/excelsis_info > > > > Sitz Stuttgart > > Amtsgericht Stuttgart, HRB 21104 > > Geschäftsführer: Christian Sauter, Dr. Nils Herda, Frank Wolf > > > > -Ursprüngliche Nachricht- > > Von: Ernesto Reinaldo Barreiro [mailto:reier...@gmail.com] > > Gesendet: Dienstag, 6. Oktober 2009 11:31 > > An: users@wicket.apache.org > > Betreff: Re: Send file to client via Ajax > > > > Just sent it on my last e-mail! Here it is again! > > import org.apache.wicket.IResourceListener; > > import org.apache.wicket.markup.html.WebMarkupContainer; > > > > /** > > * @author Ernesto Reinaldo Barreiro (reier...@gmail.com) > > * > > */ > > public class DocumentResourceListener extends WebMarkupContainer > implements > > IResourceListener > > { > > private static final long serialVersionUID = 1L; > > private IResourceListener resourceListener; > > > > /** > > * Constructor receiving an IResourceListener.. > > * > > * @param id > > * @param resourceListener > > */ > > public DocumentResourceListener(final String id, IResourceListener > > resourceListener) > > { > > super(id); > > this.resourceListener = resourceListener; > > } > > > > /** > > * Gets the url to use for this link. > > * > > * @return The URL that this link links to > > */ > > protected CharSequence getURL() > > { > > return urlFor(IResourceListener.INTERFACE); > > } > > > > > > @Override > > protected boolean getStatelessHint() > > { > > return false; > > } > > public void onResourceRequested() { > > this.resourceListener.onResourceRequested(); > > } > > } > > > > This is just a trick to have component that generates file contents on > the > > same page! I think you could used mounted resources as well, or just a > > dedicated servlet if you want to get file generation out of wicket! > > > > Best, > > > > Ernesto > > > > On Tue, Oct 6, 2009 at 11:24 AM, Giambalvo, Christian < > > christian.giamba...@excelsisnet.com> wrote: > > > > > Yes it would be usefull. > > > But where does DocumentResourceListener came from? > > > I'm using wicket 1.3.6 and DocumentResourceListener is not available. > > > > > > Thanks > > > > > > Mit freundlichen Grüßen > > > Christian Giambalvo > > > -- > > > Fachinformatiker für Anwendungsentwicklung > > > > > > EXCELSIS Informationssysteme GmbH > > > Wilhelmsplatz 8 - 70182 Stuttgart > > > Mobile +49 176 196 32 406 > > > Office +49 711 6 20 30 406 > > > christian.giamba...@excelsisnet.com > > > www.excelsi
AW: Send file to client via Ajax
Yes, please add it. Mit freundlichen Grüßen Christian Giambalvo -- Fachinformatiker für Anwendungsentwicklung EXCELSIS Informationssysteme GmbH Wilhelmsplatz 8 - 70182 Stuttgart Mobile +49 176 196 32 406 Office +49 711 6 20 30 406 christian.giamba...@excelsisnet.com www.excelsisnet.com www.twitter.com/excelsis_info Sitz Stuttgart Amtsgericht Stuttgart, HRB 21104 Geschäftsführer: Christian Sauter, Dr. Nils Herda, Frank Wolf -Ursprüngliche Nachricht- Von: Ernesto Reinaldo Barreiro [mailto:reier...@gmail.com] Gesendet: Dienstag, 6. Oktober 2009 11:48 An: users@wicket.apache.org Betreff: Re: Send file to client via Ajax Nice to hear it was of some help! I have learned a bit too while doing it:-) Cheers, Ernesto P.S. Shall I add this to a Wiki page?... when I find the time;-) On Tue, Oct 6, 2009 at 11:39 AM, Giambalvo, Christian < christian.giamba...@excelsisnet.com> wrote: > Works like a charm. > I think i've learned something about resource download via ajax. > Thanks for hat. > > > Mit freundlichen Grüßen > Christian Giambalvo > -- > Fachinformatiker für Anwendungsentwicklung > > EXCELSIS Informationssysteme GmbH > Wilhelmsplatz 8 - 70182 Stuttgart > Mobile +49 176 196 32 406 > Office +49 711 6 20 30 406 > christian.giamba...@excelsisnet.com > www.excelsisnet.com > www.twitter.com/excelsis_info > > Sitz Stuttgart > Amtsgericht Stuttgart, HRB 21104 > Geschäftsführer: Christian Sauter, Dr. Nils Herda, Frank Wolf > > -Ursprüngliche Nachricht- > Von: Ernesto Reinaldo Barreiro [mailto:reier...@gmail.com] > Gesendet: Dienstag, 6. Oktober 2009 11:31 > An: users@wicket.apache.org > Betreff: Re: Send file to client via Ajax > > Just sent it on my last e-mail! Here it is again! > import org.apache.wicket.IResourceListener; > import org.apache.wicket.markup.html.WebMarkupContainer; > > /** > * @author Ernesto Reinaldo Barreiro (reier...@gmail.com) > * > */ > public class DocumentResourceListener extends WebMarkupContainer implements > IResourceListener > { > private static final long serialVersionUID = 1L; > private IResourceListener resourceListener; > > /** > * Constructor receiving an IResourceListener.. > * > * @param id > * @param resourceListener > */ > public DocumentResourceListener(final String id, IResourceListener > resourceListener) > { > super(id); > this.resourceListener = resourceListener; > } > > /** > * Gets the url to use for this link. > * > * @return The URL that this link links to > */ > protected CharSequence getURL() > { > return urlFor(IResourceListener.INTERFACE); > } > > > @Override > protected boolean getStatelessHint() > { > return false; > } > public void onResourceRequested() { > this.resourceListener.onResourceRequested(); > } > } > > This is just a trick to have component that generates file contents on the > same page! I think you could used mounted resources as well, or just a > dedicated servlet if you want to get file generation out of wicket! > > Best, > > Ernesto > > On Tue, Oct 6, 2009 at 11:24 AM, Giambalvo, Christian < > christian.giamba...@excelsisnet.com> wrote: > > > Yes it would be usefull. > > But where does DocumentResourceListener came from? > > I'm using wicket 1.3.6 and DocumentResourceListener is not available. > > > > Thanks > > > > Mit freundlichen Grüßen > > Christian Giambalvo > > -- > > Fachinformatiker für Anwendungsentwicklung > > > > EXCELSIS Informationssysteme GmbH > > Wilhelmsplatz 8 - 70182 Stuttgart > > Mobile +49 176 196 32 406 > > Office +49 711 6 20 30 406 > > christian.giamba...@excelsisnet.com > > www.excelsisnet.com > > > > Sitz Stuttgart > > Amtsgericht Stuttgart, HRB 21104 > > Geschäftsführer: Christian Sauter, Dr. Nils Herda, Frank Wolf > > > > > > -Ursprüngliche Nachricht- > > Von: Ernesto Reinaldo Barreiro [mailto:reier...@gmail.com] > > Gesendet: Dienstag, 6. Oktober 2009 09:54 > > An: users@wicket.apache.org > > Betreff: Re: Send file to client via Ajax > > > > Hi Cristian, > > I've got it working! > > > > Just place all the following files at the same package and you will get a > > working example (I tested them with FF35 and IE7). > > > > import org.apache.wicket.ajax.AjaxRequestTarget; > > import org.apache.wicket.ajax.markup.html.AjaxLink; > > import org.apache.wicket.markup.html.WebPage; > > import org.apache.wicket.markup.html.basic.Label; > > import org.apache.wicket.model.AbstractReadOnlyModel; > > > > /** > > * @author Ernesto Reinal
Re: Send file to client via Ajax
Nice to hear it was of some help! I have learned a bit too while doing it:-) Cheers, Ernesto P.S. Shall I add this to a Wiki page?... when I find the time;-) On Tue, Oct 6, 2009 at 11:39 AM, Giambalvo, Christian < christian.giamba...@excelsisnet.com> wrote: > Works like a charm. > I think i've learned something about resource download via ajax. > Thanks for hat. > > > Mit freundlichen Grüßen > Christian Giambalvo > -- > Fachinformatiker für Anwendungsentwicklung > > EXCELSIS Informationssysteme GmbH > Wilhelmsplatz 8 - 70182 Stuttgart > Mobile +49 176 196 32 406 > Office +49 711 6 20 30 406 > christian.giamba...@excelsisnet.com > www.excelsisnet.com > www.twitter.com/excelsis_info > > Sitz Stuttgart > Amtsgericht Stuttgart, HRB 21104 > Geschäftsführer: Christian Sauter, Dr. Nils Herda, Frank Wolf > > -Ursprüngliche Nachricht- > Von: Ernesto Reinaldo Barreiro [mailto:reier...@gmail.com] > Gesendet: Dienstag, 6. Oktober 2009 11:31 > An: users@wicket.apache.org > Betreff: Re: Send file to client via Ajax > > Just sent it on my last e-mail! Here it is again! > import org.apache.wicket.IResourceListener; > import org.apache.wicket.markup.html.WebMarkupContainer; > > /** > * @author Ernesto Reinaldo Barreiro (reier...@gmail.com) > * > */ > public class DocumentResourceListener extends WebMarkupContainer implements > IResourceListener > { > private static final long serialVersionUID = 1L; > private IResourceListener resourceListener; > > /** > * Constructor receiving an IResourceListener.. > * > * @param id > * @param resourceListener > */ > public DocumentResourceListener(final String id, IResourceListener > resourceListener) > { > super(id); > this.resourceListener = resourceListener; > } > > /** > * Gets the url to use for this link. > * > * @return The URL that this link links to > */ > protected CharSequence getURL() > { > return urlFor(IResourceListener.INTERFACE); > } > > > @Override > protected boolean getStatelessHint() > { > return false; > } > public void onResourceRequested() { > this.resourceListener.onResourceRequested(); > } > } > > This is just a trick to have component that generates file contents on the > same page! I think you could used mounted resources as well, or just a > dedicated servlet if you want to get file generation out of wicket! > > Best, > > Ernesto > > On Tue, Oct 6, 2009 at 11:24 AM, Giambalvo, Christian < > christian.giamba...@excelsisnet.com> wrote: > > > Yes it would be usefull. > > But where does DocumentResourceListener came from? > > I'm using wicket 1.3.6 and DocumentResourceListener is not available. > > > > Thanks > > > > Mit freundlichen Grüßen > > Christian Giambalvo > > -- > > Fachinformatiker für Anwendungsentwicklung > > > > EXCELSIS Informationssysteme GmbH > > Wilhelmsplatz 8 - 70182 Stuttgart > > Mobile +49 176 196 32 406 > > Office +49 711 6 20 30 406 > > christian.giamba...@excelsisnet.com > > www.excelsisnet.com > > > > Sitz Stuttgart > > Amtsgericht Stuttgart, HRB 21104 > > Geschäftsführer: Christian Sauter, Dr. Nils Herda, Frank Wolf > > > > > > -Ursprüngliche Nachricht- > > Von: Ernesto Reinaldo Barreiro [mailto:reier...@gmail.com] > > Gesendet: Dienstag, 6. Oktober 2009 09:54 > > An: users@wicket.apache.org > > Betreff: Re: Send file to client via Ajax > > > > Hi Cristian, > > I've got it working! > > > > Just place all the following files at the same package and you will get a > > working example (I tested them with FF35 and IE7). > > > > import org.apache.wicket.ajax.AjaxRequestTarget; > > import org.apache.wicket.ajax.markup.html.AjaxLink; > > import org.apache.wicket.markup.html.WebPage; > > import org.apache.wicket.markup.html.basic.Label; > > import org.apache.wicket.model.AbstractReadOnlyModel; > > > > /** > > * @author Ernesto Reinaldo Barreiro (reier...@gmail.com) > > * > > */ > > public class TestPage extends WebPage{ > > > > private Label text; > > private String labelText = "Hi!"; > > private DocumentResourceListener documentResourceListener; > > > > /** > > * > > */ > > public TestPage() { > > AjaxLink link = new AjaxLink("link") { > > private static final long serialVersionUID = 1L; > > > > @Override > > public void onClick(AjaxRequestTarget target) { > > TestPage.this.lab
AW: Send file to client via Ajax
Works like a charm. I think i've learned something about resource download via ajax. Thanks for hat. Mit freundlichen Grüßen Christian Giambalvo -- Fachinformatiker für Anwendungsentwicklung EXCELSIS Informationssysteme GmbH Wilhelmsplatz 8 - 70182 Stuttgart Mobile +49 176 196 32 406 Office +49 711 6 20 30 406 christian.giamba...@excelsisnet.com www.excelsisnet.com www.twitter.com/excelsis_info Sitz Stuttgart Amtsgericht Stuttgart, HRB 21104 Geschäftsführer: Christian Sauter, Dr. Nils Herda, Frank Wolf -Ursprüngliche Nachricht- Von: Ernesto Reinaldo Barreiro [mailto:reier...@gmail.com] Gesendet: Dienstag, 6. Oktober 2009 11:31 An: users@wicket.apache.org Betreff: Re: Send file to client via Ajax Just sent it on my last e-mail! Here it is again! import org.apache.wicket.IResourceListener; import org.apache.wicket.markup.html.WebMarkupContainer; /** * @author Ernesto Reinaldo Barreiro (reier...@gmail.com) * */ public class DocumentResourceListener extends WebMarkupContainer implements IResourceListener { private static final long serialVersionUID = 1L; private IResourceListener resourceListener; /** * Constructor receiving an IResourceListener.. * * @param id * @param resourceListener */ public DocumentResourceListener(final String id, IResourceListener resourceListener) { super(id); this.resourceListener = resourceListener; } /** * Gets the url to use for this link. * * @return The URL that this link links to */ protected CharSequence getURL() { return urlFor(IResourceListener.INTERFACE); } @Override protected boolean getStatelessHint() { return false; } public void onResourceRequested() { this.resourceListener.onResourceRequested(); } } This is just a trick to have component that generates file contents on the same page! I think you could used mounted resources as well, or just a dedicated servlet if you want to get file generation out of wicket! Best, Ernesto On Tue, Oct 6, 2009 at 11:24 AM, Giambalvo, Christian < christian.giamba...@excelsisnet.com> wrote: > Yes it would be usefull. > But where does DocumentResourceListener came from? > I'm using wicket 1.3.6 and DocumentResourceListener is not available. > > Thanks > > Mit freundlichen Grüßen > Christian Giambalvo > -- > Fachinformatiker für Anwendungsentwicklung > > EXCELSIS Informationssysteme GmbH > Wilhelmsplatz 8 - 70182 Stuttgart > Mobile +49 176 196 32 406 > Office +49 711 6 20 30 406 > christian.giamba...@excelsisnet.com > www.excelsisnet.com > > Sitz Stuttgart > Amtsgericht Stuttgart, HRB 21104 > Geschäftsführer: Christian Sauter, Dr. Nils Herda, Frank Wolf > > > -Ursprüngliche Nachricht- > Von: Ernesto Reinaldo Barreiro [mailto:reier...@gmail.com] > Gesendet: Dienstag, 6. Oktober 2009 09:54 > An: users@wicket.apache.org > Betreff: Re: Send file to client via Ajax > > Hi Cristian, > I've got it working! > > Just place all the following files at the same package and you will get a > working example (I tested them with FF35 and IE7). > > import org.apache.wicket.ajax.AjaxRequestTarget; > import org.apache.wicket.ajax.markup.html.AjaxLink; > import org.apache.wicket.markup.html.WebPage; > import org.apache.wicket.markup.html.basic.Label; > import org.apache.wicket.model.AbstractReadOnlyModel; > > /** > * @author Ernesto Reinaldo Barreiro (reier...@gmail.com) > * > */ > public class TestPage extends WebPage{ > > private Label text; > private String labelText = "Hi!"; > private DocumentResourceListener documentResourceListener; > > /** > * > */ > public TestPage() { > AjaxLink link = new AjaxLink("link") { > private static final long serialVersionUID = 1L; > > @Override > public void onClick(AjaxRequestTarget target) { > TestPage.this.labelText = "Hi! and donwload image!"; > if(target!= null) { > target.addComponent(TestPage.this.text); > String url = documentResourceListener.getURL().toString(); > target.appendJavascript(";alert('Hi');window.location.href='"+url+"';"); > } > } > }; > add(link); > text = new Label("text", new AbstractReadOnlyModel() { > private static final long serialVersionUID = 1L; > > @Override > public String getObject() { > return TestPage.this.labelText; > } > }); > text.setOutputMarkupId(true); > add(text); > documentResourceListener = new DocumentResourceListener("listener", new > MyPdfResource()); > add(documentResourceListener); > } > > } > > --- > >"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> > > > > > Click Me > > > > > > - > > import java.io.Byte
Re: Send file to client via Ajax
Just sent it on my last e-mail! Here it is again! import org.apache.wicket.IResourceListener; import org.apache.wicket.markup.html.WebMarkupContainer; /** * @author Ernesto Reinaldo Barreiro (reier...@gmail.com) * */ public class DocumentResourceListener extends WebMarkupContainer implements IResourceListener { private static final long serialVersionUID = 1L; private IResourceListener resourceListener; /** * Constructor receiving an IResourceListener.. * * @param id * @param resourceListener */ public DocumentResourceListener(final String id, IResourceListener resourceListener) { super(id); this.resourceListener = resourceListener; } /** * Gets the url to use for this link. * * @return The URL that this link links to */ protected CharSequence getURL() { return urlFor(IResourceListener.INTERFACE); } @Override protected boolean getStatelessHint() { return false; } public void onResourceRequested() { this.resourceListener.onResourceRequested(); } } This is just a trick to have component that generates file contents on the same page! I think you could used mounted resources as well, or just a dedicated servlet if you want to get file generation out of wicket! Best, Ernesto On Tue, Oct 6, 2009 at 11:24 AM, Giambalvo, Christian < christian.giamba...@excelsisnet.com> wrote: > Yes it would be usefull. > But where does DocumentResourceListener came from? > I'm using wicket 1.3.6 and DocumentResourceListener is not available. > > Thanks > > Mit freundlichen Grüßen > Christian Giambalvo > -- > Fachinformatiker für Anwendungsentwicklung > > EXCELSIS Informationssysteme GmbH > Wilhelmsplatz 8 - 70182 Stuttgart > Mobile +49 176 196 32 406 > Office +49 711 6 20 30 406 > christian.giamba...@excelsisnet.com > www.excelsisnet.com > > Sitz Stuttgart > Amtsgericht Stuttgart, HRB 21104 > Geschäftsführer: Christian Sauter, Dr. Nils Herda, Frank Wolf > > > -Ursprüngliche Nachricht- > Von: Ernesto Reinaldo Barreiro [mailto:reier...@gmail.com] > Gesendet: Dienstag, 6. Oktober 2009 09:54 > An: users@wicket.apache.org > Betreff: Re: Send file to client via Ajax > > Hi Cristian, > I've got it working! > > Just place all the following files at the same package and you will get a > working example (I tested them with FF35 and IE7). > > import org.apache.wicket.ajax.AjaxRequestTarget; > import org.apache.wicket.ajax.markup.html.AjaxLink; > import org.apache.wicket.markup.html.WebPage; > import org.apache.wicket.markup.html.basic.Label; > import org.apache.wicket.model.AbstractReadOnlyModel; > > /** > * @author Ernesto Reinaldo Barreiro (reier...@gmail.com) > * > */ > public class TestPage extends WebPage{ > > private Label text; > private String labelText = "Hi!"; > private DocumentResourceListener documentResourceListener; > > /** > * > */ > public TestPage() { > AjaxLink link = new AjaxLink("link") { > private static final long serialVersionUID = 1L; > > @Override > public void onClick(AjaxRequestTarget target) { > TestPage.this.labelText = "Hi! and donwload image!"; > if(target!= null) { > target.addComponent(TestPage.this.text); > String url = documentResourceListener.getURL().toString(); > target.appendJavascript(";alert('Hi');window.location.href='"+url+"';"); > } > } > }; > add(link); > text = new Label("text", new AbstractReadOnlyModel() { > private static final long serialVersionUID = 1L; > > @Override > public String getObject() { > return TestPage.this.labelText; > } > }); > text.setOutputMarkupId(true); > add(text); > documentResourceListener = new DocumentResourceListener("listener", new > MyPdfResource()); > add(documentResourceListener); > } > > } > > --- > >"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> > > > > > Click Me > > > > > > - > > import java.io.ByteArrayOutputStream; > import java.io.IOException; > import java.io.InputStream; > import java.io.OutputStream; > > import org.apache.wicket.markup.html.DynamicWebResource; > import org.apache.wicket.protocol.http.WebResponse; > > /** > * @author Ernesto Reinaldo Barreiro (reier...@gmail.com) > * > */ > public class MyPdfResource extends DynamicWebResource { > > private static final long serialVersionUID = 1L; > > static int BUFFER_SIZE = 10*1024; > /** > * > */ > public MyPdfResource() { > } > > /* (non-Javadoc) > * @see org.apache.wicket.markup.html.DynamicWebResource#getResourceState() > */ > @Override > protected ResourceStat
AW: Send file to client via Ajax
Yes it would be usefull. But where does DocumentResourceListener came from? I'm using wicket 1.3.6 and DocumentResourceListener is not available. Thanks Mit freundlichen Grüßen Christian Giambalvo -- Fachinformatiker für Anwendungsentwicklung EXCELSIS Informationssysteme GmbH Wilhelmsplatz 8 - 70182 Stuttgart Mobile +49 176 196 32 406 Office +49 711 6 20 30 406 christian.giamba...@excelsisnet.com www.excelsisnet.com Sitz Stuttgart Amtsgericht Stuttgart, HRB 21104 Geschäftsführer: Christian Sauter, Dr. Nils Herda, Frank Wolf -Ursprüngliche Nachricht- Von: Ernesto Reinaldo Barreiro [mailto:reier...@gmail.com] Gesendet: Dienstag, 6. Oktober 2009 09:54 An: users@wicket.apache.org Betreff: Re: Send file to client via Ajax Hi Cristian, I've got it working! Just place all the following files at the same package and you will get a working example (I tested them with FF35 and IE7). import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.ajax.markup.html.AjaxLink; import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.model.AbstractReadOnlyModel; /** * @author Ernesto Reinaldo Barreiro (reier...@gmail.com) * */ public class TestPage extends WebPage{ private Label text; private String labelText = "Hi!"; private DocumentResourceListener documentResourceListener; /** * */ public TestPage() { AjaxLink link = new AjaxLink("link") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { TestPage.this.labelText = "Hi! and donwload image!"; if(target!= null) { target.addComponent(TestPage.this.text); String url = documentResourceListener.getURL().toString(); target.appendJavascript(";alert('Hi');window.location.href='"+url+"';"); } } }; add(link); text = new Label("text", new AbstractReadOnlyModel() { private static final long serialVersionUID = 1L; @Override public String getObject() { return TestPage.this.labelText; } }); text.setOutputMarkupId(true); add(text); documentResourceListener = new DocumentResourceListener("listener", new MyPdfResource()); add(documentResourceListener); } } --- http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> Click Me - import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import org.apache.wicket.markup.html.DynamicWebResource; import org.apache.wicket.protocol.http.WebResponse; /** * @author Ernesto Reinaldo Barreiro (reier...@gmail.com) * */ public class MyPdfResource extends DynamicWebResource { private static final long serialVersionUID = 1L; static int BUFFER_SIZE = 10*1024; /** * */ public MyPdfResource() { } /* (non-Javadoc) * @see org.apache.wicket.markup.html.DynamicWebResource#getResourceState() */ @Override protected ResourceState getResourceState() { return new ResourceState() { @Override public String getContentType() { return "application/pdf"; } @Override public byte[] getData() { try { return bytes(MyPdfResource.class.getResourceAsStream("jta-1_1-spec.pdf")); } catch (Exception e) { return null; } } }; } public static byte[] bytes(InputStream is) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); copy(is, out); return out.toByteArray(); } @Override protected void setHeaders(WebResponse response) { super.setHeaders(response); response.setAttachmentHeader("jta-1_1-spec.pdf"); } public static void copy(InputStream is, OutputStream os) throws IOException { byte[] buf = new byte[BUFFER_SIZE]; while (true) { int tam = is.read(buf); if (tam == -1) { return; } os.write(buf, 0, tam); } } } Just replace "jta-1_1-spec.pdf" with your own PDF file on MyPdfResource and the exampel should work. An important bit here if @Override protected void setHeaders(WebResponse response) { response.setAttachmentHeader("jta-1_1-spec.pdf"); } which makes the file to treated as an attachment instead of replacing the current page. Best, Ernesto P.S. Would it useful to add this to Wicket's wiki? - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Send file to client via Ajax
Sorry, I forgot a class import org.apache.wicket.IResourceListener; import org.apache.wicket.markup.html.WebMarkupContainer; /** * @author Ernesto Reinaldo Barreiro (reier...@gmail.com) * */ public class DocumentResourceListener extends WebMarkupContainer implements IResourceListener { private static final long serialVersionUID = 1L; private IResourceListener resourceListener; /** * Constructor receiving an IResourceListener.. * * @param id * @param resourceListener */ public DocumentResourceListener(final String id, IResourceListener resourceListener) { super(id); this.resourceListener = resourceListener; } /** * Gets the url to use for this link. * * @return The URL that this link links to */ protected CharSequence getURL() { return urlFor(IResourceListener.INTERFACE); } @Override protected boolean getStatelessHint() { return false; } public void onResourceRequested() { this.resourceListener.onResourceRequested(); } } Best, Ernesto On Tue, Oct 6, 2009 at 9:53 AM, Ernesto Reinaldo Barreiro < reier...@gmail.com> wrote: > Hi Cristian, > I've got it working! > > Just place all the following files at the same package and you will get a > working example (I tested them with FF35 and IE7). > > import org.apache.wicket.ajax.AjaxRequestTarget; > import org.apache.wicket.ajax.markup.html.AjaxLink; > import org.apache.wicket.markup.html.WebPage; > import org.apache.wicket.markup.html.basic.Label; > import org.apache.wicket.model.AbstractReadOnlyModel; > > /** > * @author Ernesto Reinaldo Barreiro (reier...@gmail.com) > * > */ > public class TestPage extends WebPage{ > > private Label text; > private String labelText = "Hi!"; > private DocumentResourceListener documentResourceListener; > > /** > * > */ > public TestPage() { > AjaxLink link = new AjaxLink("link") { > private static final long serialVersionUID = 1L; > > @Override > public void onClick(AjaxRequestTarget target) { > TestPage.this.labelText = "Hi! and donwload image!"; > if(target!= null) { > target.addComponent(TestPage.this.text); > String url = documentResourceListener.getURL().toString(); > target.appendJavascript(";alert('Hi');window.location.href='"+url+"';"); > } > } > }; > add(link); > text = new Label("text", new AbstractReadOnlyModel() { > private static final long serialVersionUID = 1L; > > @Override > public String getObject() { > return TestPage.this.labelText; > } > }); > text.setOutputMarkupId(true); > add(text); > documentResourceListener = new DocumentResourceListener("listener", new > MyPdfResource()); > add(documentResourceListener); > } > > } > > --- > > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> > > > > > Click Me > > > > > > - > > import java.io.ByteArrayOutputStream; > import java.io.IOException; > import java.io.InputStream; > import java.io.OutputStream; > > import org.apache.wicket.markup.html.DynamicWebResource; > import org.apache.wicket.protocol.http.WebResponse; > > /** > * @author Ernesto Reinaldo Barreiro (reier...@gmail.com) > * > */ > public class MyPdfResource extends DynamicWebResource { > > private static final long serialVersionUID = 1L; > > static int BUFFER_SIZE = 10*1024; > /** > * > */ > public MyPdfResource() { > } > > /* (non-Javadoc) > * @see org.apache.wicket.markup.html.DynamicWebResource#getResourceState() > */ > @Override > protected ResourceState getResourceState() { > return new ResourceState() { > @Override > public String getContentType() { > return "application/pdf"; > } > @Override > public byte[] getData() { > try { > return > bytes(MyPdfResource.class.getResourceAsStream("jta-1_1-spec.pdf")); > } catch (Exception e) { > return null; > } > } > }; > } > public static byte[] bytes(InputStream is) throws IOException { > ByteArrayOutputStream out = new ByteArrayOutputStream(); > copy(is, out); > return out.toByteArray(); > } > @Override > protected void setHeaders(WebResponse response) { > super.setHeaders(response); > response.setAttachmentHeader("jta-1_1-spec.pdf"); > } > public static void copy(InputStream is, OutputStream os) throws > IOException { > byte[] buf = new byte[BUFFER_SIZE]; > while (true) { > int tam = is.read(buf); > if (tam == -1) { > return; > } > os.write(buf, 0, tam); > } > } > } > > Just replace "jta-1_1-spec.pdf" with your own PDF file on MyPdfResource and > the exampel should work. An important bit here if > > @Override > protected void setHeaders(WebResponse response) { > > response.setAttachmentHeader("jta-1_1-spec.pdf"); > } > > which makes the file to treated as an attachment instead of replacing the > current page. > > Best, > > Ernesto > > P.S. Would it useful to add this to Wicket's wiki? >
Re: Send file to client via Ajax
Hi Cristian, I've got it working! Just place all the following files at the same package and you will get a working example (I tested them with FF35 and IE7). import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.ajax.markup.html.AjaxLink; import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.model.AbstractReadOnlyModel; /** * @author Ernesto Reinaldo Barreiro (reier...@gmail.com) * */ public class TestPage extends WebPage{ private Label text; private String labelText = "Hi!"; private DocumentResourceListener documentResourceListener; /** * */ public TestPage() { AjaxLink link = new AjaxLink("link") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { TestPage.this.labelText = "Hi! and donwload image!"; if(target!= null) { target.addComponent(TestPage.this.text); String url = documentResourceListener.getURL().toString(); target.appendJavascript(";alert('Hi');window.location.href='"+url+"';"); } } }; add(link); text = new Label("text", new AbstractReadOnlyModel() { private static final long serialVersionUID = 1L; @Override public String getObject() { return TestPage.this.labelText; } }); text.setOutputMarkupId(true); add(text); documentResourceListener = new DocumentResourceListener("listener", new MyPdfResource()); add(documentResourceListener); } } --- http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> Click Me - import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import org.apache.wicket.markup.html.DynamicWebResource; import org.apache.wicket.protocol.http.WebResponse; /** * @author Ernesto Reinaldo Barreiro (reier...@gmail.com) * */ public class MyPdfResource extends DynamicWebResource { private static final long serialVersionUID = 1L; static int BUFFER_SIZE = 10*1024; /** * */ public MyPdfResource() { } /* (non-Javadoc) * @see org.apache.wicket.markup.html.DynamicWebResource#getResourceState() */ @Override protected ResourceState getResourceState() { return new ResourceState() { @Override public String getContentType() { return "application/pdf"; } @Override public byte[] getData() { try { return bytes(MyPdfResource.class.getResourceAsStream("jta-1_1-spec.pdf")); } catch (Exception e) { return null; } } }; } public static byte[] bytes(InputStream is) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); copy(is, out); return out.toByteArray(); } @Override protected void setHeaders(WebResponse response) { super.setHeaders(response); response.setAttachmentHeader("jta-1_1-spec.pdf"); } public static void copy(InputStream is, OutputStream os) throws IOException { byte[] buf = new byte[BUFFER_SIZE]; while (true) { int tam = is.read(buf); if (tam == -1) { return; } os.write(buf, 0, tam); } } } Just replace "jta-1_1-spec.pdf" with your own PDF file on MyPdfResource and the exampel should work. An important bit here if @Override protected void setHeaders(WebResponse response) { response.setAttachmentHeader("jta-1_1-spec.pdf"); } which makes the file to treated as an attachment instead of replacing the current page. Best, Ernesto P.S. Would it useful to add this to Wicket's wiki?
Re: Send file to client via Ajax
Hi, I was trying to build and Example at work but I had to live... I'll try to get it working tomorrow and post it here. Essentially I was trying something similar to this. http://cwiki.apache.org/WICKET/displaying-content-eg-pdf-excel-word-in-an-iframe.html I was trying to have a component in a page that implements IResourceListener and then on the onclick on AJX link have something like if(target != null) { target.addComponent(theComponentYouWantToRepaint); String url = urlFor(ComponentImplementingIResourceListener); target.appendJavaScript("window.location.href="+url); } so, that once component is repaint you get a request back to you page asking for the resource. This is somehow similar to the example above.. Best, Ernesto On Mon, Oct 5, 2009 at 6:08 PM, Giambalvo, Christian < christian.giamba...@excelsisnet.com> wrote: > How do i get the url for the ILinkListener? > There is no corresponding urlFor() method. > > Mit freundlichen Grüßen > Christian Giambalvo > -- > Fachinformatiker für Anwendungsentwicklung > > EXCELSIS Informationssysteme GmbH > Wilhelmsplatz 8 - 70182 Stuttgart > Mobile +49 176 196 32 406 > Office +49 711 6 20 30 406 > christian.giamba...@excelsisnet.com > www.excelsisnet.com > > Sitz Stuttgart > Amtsgericht Stuttgart, HRB 21104 > Geschäftsführer: Christian Sauter, Dr. Nils Herda, Frank Wolf > > > -Ursprüngliche Nachricht- > Von: Ernesto Reinaldo Barreiro [mailto:reier...@gmail.com] > Gesendet: Montag, 5. Oktober 2009 16:22 > An: users@wicket.apache.org > Betreff: Re: Send file to client via Ajax > > Maybe you could repaint via AJAX and then use > target.appendJavascript("window.location.href=´URL´"); > > Where the URL is the URL of an ILinkListener generating you file... There > was someone asking something similar not long ago. > > Best, > > Ernesto > > > On Mon, Oct 5, 2009 at 4:10 PM, Giambalvo, Christian < > christian.giamba...@excelsisnet.com> wrote: > > > It's more general question. > > Maybe i need to repaint some parts and send a file. > > > > Mit freundlichen Grüßen > > Christian Giambalvo > > -- > > Fachinformatiker für Anwendungsentwicklung > > > > EXCELSIS Informationssysteme GmbH > > Wilhelmsplatz 8 - 70182 Stuttgart > > Mobile +49 176 196 32 406 > > Office +49 711 6 20 30 406 > > christian.giamba...@excelsisnet.com > > www.excelsisnet.com > > > > Sitz Stuttgart > > Amtsgericht Stuttgart, HRB 21104 > > Geschäftsführer: Christian Sauter, Dr. Nils Herda, Frank Wolf > > > > > > -Ursprüngliche Nachricht- > > Von: Martin Grigorov [mailto:mcgreg...@e-card.bg] > > Gesendet: Montag, 5. Oktober 2009 15:56 > > An: users@wicket.apache.org > > Betreff: Re: Send file to client via Ajax > > > > why do you want to use AjaxFallbackButton ? > > you will not re-paint part of the page > > > > use ResourceLink to download the file > > > > El lun, 05-10-2009 a las 15:36 +0200, Giambalvo, Christian escribió: > > > Hi all, > > > > > > simple question :) > > > > > > how to send a dynamicly generated file (as byte array) through an > > ajaxfallbackbutton tot he client? > > > > > > > > > Mit freundlichen Grüßen > > > Christian Giambalvo > > > -- > > > Fachinformatiker für Anwendungsentwicklung > > > > > > EXCELSIS Informationssysteme GmbH > > > Wilhelmsplatz 8 - 70182 Stuttgart > > > Mobile +49 176 196 32 406 > > > Office +49 711 6 20 30 406 > > > christian.giamba...@excelsisnet.com > > > www.excelsisnet.com > > > > > > Sitz Stuttgart > > > Amtsgericht Stuttgart, HRB 21104 > > > Geschäftsführer: Christian Sauter, Dr. Nils Herda, Frank Wolf > > > > > > - > > 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 > >
AW: Send file to client via Ajax
How do i get the url for the ILinkListener? There is no corresponding urlFor() method. Mit freundlichen Grüßen Christian Giambalvo -- Fachinformatiker für Anwendungsentwicklung EXCELSIS Informationssysteme GmbH Wilhelmsplatz 8 - 70182 Stuttgart Mobile +49 176 196 32 406 Office +49 711 6 20 30 406 christian.giamba...@excelsisnet.com www.excelsisnet.com Sitz Stuttgart Amtsgericht Stuttgart, HRB 21104 Geschäftsführer: Christian Sauter, Dr. Nils Herda, Frank Wolf -Ursprüngliche Nachricht- Von: Ernesto Reinaldo Barreiro [mailto:reier...@gmail.com] Gesendet: Montag, 5. Oktober 2009 16:22 An: users@wicket.apache.org Betreff: Re: Send file to client via Ajax Maybe you could repaint via AJAX and then use target.appendJavascript("window.location.href=´URL´"); Where the URL is the URL of an ILinkListener generating you file... There was someone asking something similar not long ago. Best, Ernesto On Mon, Oct 5, 2009 at 4:10 PM, Giambalvo, Christian < christian.giamba...@excelsisnet.com> wrote: > It's more general question. > Maybe i need to repaint some parts and send a file. > > Mit freundlichen Grüßen > Christian Giambalvo > -- > Fachinformatiker für Anwendungsentwicklung > > EXCELSIS Informationssysteme GmbH > Wilhelmsplatz 8 - 70182 Stuttgart > Mobile +49 176 196 32 406 > Office +49 711 6 20 30 406 > christian.giamba...@excelsisnet.com > www.excelsisnet.com > > Sitz Stuttgart > Amtsgericht Stuttgart, HRB 21104 > Geschäftsführer: Christian Sauter, Dr. Nils Herda, Frank Wolf > > > -Ursprüngliche Nachricht- > Von: Martin Grigorov [mailto:mcgreg...@e-card.bg] > Gesendet: Montag, 5. Oktober 2009 15:56 > An: users@wicket.apache.org > Betreff: Re: Send file to client via Ajax > > why do you want to use AjaxFallbackButton ? > you will not re-paint part of the page > > use ResourceLink to download the file > > El lun, 05-10-2009 a las 15:36 +0200, Giambalvo, Christian escribió: > > Hi all, > > > > simple question :) > > > > how to send a dynamicly generated file (as byte array) through an > ajaxfallbackbutton tot he client? > > > > > > Mit freundlichen Grüßen > > Christian Giambalvo > > -- > > Fachinformatiker für Anwendungsentwicklung > > > > EXCELSIS Informationssysteme GmbH > > Wilhelmsplatz 8 - 70182 Stuttgart > > Mobile +49 176 196 32 406 > > Office +49 711 6 20 30 406 > > christian.giamba...@excelsisnet.com > > www.excelsisnet.com > > > > Sitz Stuttgart > > Amtsgericht Stuttgart, HRB 21104 > > Geschäftsführer: Christian Sauter, Dr. Nils Herda, Frank Wolf > > > - > 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
AW: Send file to client via Ajax
Could you give me an example? Mit freundlichen Grüßen Christian Giambalvo -- Fachinformatiker für Anwendungsentwicklung EXCELSIS Informationssysteme GmbH Wilhelmsplatz 8 - 70182 Stuttgart Mobile +49 176 196 32 406 Office +49 711 6 20 30 406 christian.giamba...@excelsisnet.com www.excelsisnet.com Sitz Stuttgart Amtsgericht Stuttgart, HRB 21104 Geschäftsführer: Christian Sauter, Dr. Nils Herda, Frank Wolf -Ursprüngliche Nachricht- Von: Ernesto Reinaldo Barreiro [mailto:reier...@gmail.com] Gesendet: Montag, 5. Oktober 2009 16:22 An: users@wicket.apache.org Betreff: Re: Send file to client via Ajax Maybe you could repaint via AJAX and then use target.appendJavascript("window.location.href=´URL´"); Where the URL is the URL of an ILinkListener generating you file... There was someone asking something similar not long ago. Best, Ernesto On Mon, Oct 5, 2009 at 4:10 PM, Giambalvo, Christian < christian.giamba...@excelsisnet.com> wrote: > It's more general question. > Maybe i need to repaint some parts and send a file. > > Mit freundlichen Grüßen > Christian Giambalvo > -- > Fachinformatiker für Anwendungsentwicklung > > EXCELSIS Informationssysteme GmbH > Wilhelmsplatz 8 - 70182 Stuttgart > Mobile +49 176 196 32 406 > Office +49 711 6 20 30 406 > christian.giamba...@excelsisnet.com > www.excelsisnet.com > > Sitz Stuttgart > Amtsgericht Stuttgart, HRB 21104 > Geschäftsführer: Christian Sauter, Dr. Nils Herda, Frank Wolf > > > -Ursprüngliche Nachricht- > Von: Martin Grigorov [mailto:mcgreg...@e-card.bg] > Gesendet: Montag, 5. Oktober 2009 15:56 > An: users@wicket.apache.org > Betreff: Re: Send file to client via Ajax > > why do you want to use AjaxFallbackButton ? > you will not re-paint part of the page > > use ResourceLink to download the file > > El lun, 05-10-2009 a las 15:36 +0200, Giambalvo, Christian escribió: > > Hi all, > > > > simple question :) > > > > how to send a dynamicly generated file (as byte array) through an > ajaxfallbackbutton tot he client? > > > > > > Mit freundlichen Grüßen > > Christian Giambalvo > > -- > > Fachinformatiker für Anwendungsentwicklung > > > > EXCELSIS Informationssysteme GmbH > > Wilhelmsplatz 8 - 70182 Stuttgart > > Mobile +49 176 196 32 406 > > Office +49 711 6 20 30 406 > > christian.giamba...@excelsisnet.com > > www.excelsisnet.com > > > > Sitz Stuttgart > > Amtsgericht Stuttgart, HRB 21104 > > Geschäftsführer: Christian Sauter, Dr. Nils Herda, Frank Wolf > > > - > 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
Re: Send file to client via Ajax
Maybe you could repaint via AJAX and then use target.appendJavascript("window.location.href=´URL´"); Where the URL is the URL of an ILinkListener generating you file... There was someone asking something similar not long ago. Best, Ernesto On Mon, Oct 5, 2009 at 4:10 PM, Giambalvo, Christian < christian.giamba...@excelsisnet.com> wrote: > It's more general question. > Maybe i need to repaint some parts and send a file. > > Mit freundlichen Grüßen > Christian Giambalvo > -- > Fachinformatiker für Anwendungsentwicklung > > EXCELSIS Informationssysteme GmbH > Wilhelmsplatz 8 - 70182 Stuttgart > Mobile +49 176 196 32 406 > Office +49 711 6 20 30 406 > christian.giamba...@excelsisnet.com > www.excelsisnet.com > > Sitz Stuttgart > Amtsgericht Stuttgart, HRB 21104 > Geschäftsführer: Christian Sauter, Dr. Nils Herda, Frank Wolf > > > -Ursprüngliche Nachricht- > Von: Martin Grigorov [mailto:mcgreg...@e-card.bg] > Gesendet: Montag, 5. Oktober 2009 15:56 > An: users@wicket.apache.org > Betreff: Re: Send file to client via Ajax > > why do you want to use AjaxFallbackButton ? > you will not re-paint part of the page > > use ResourceLink to download the file > > El lun, 05-10-2009 a las 15:36 +0200, Giambalvo, Christian escribió: > > Hi all, > > > > simple question :) > > > > how to send a dynamicly generated file (as byte array) through an > ajaxfallbackbutton tot he client? > > > > > > Mit freundlichen Grüßen > > Christian Giambalvo > > -- > > Fachinformatiker für Anwendungsentwicklung > > > > EXCELSIS Informationssysteme GmbH > > Wilhelmsplatz 8 - 70182 Stuttgart > > Mobile +49 176 196 32 406 > > Office +49 711 6 20 30 406 > > christian.giamba...@excelsisnet.com > > www.excelsisnet.com > > > > Sitz Stuttgart > > Amtsgericht Stuttgart, HRB 21104 > > Geschäftsführer: Christian Sauter, Dr. Nils Herda, Frank Wolf > > > - > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > >
AW: Send file to client via Ajax
It's more general question. Maybe i need to repaint some parts and send a file. Mit freundlichen Grüßen Christian Giambalvo -- Fachinformatiker für Anwendungsentwicklung EXCELSIS Informationssysteme GmbH Wilhelmsplatz 8 - 70182 Stuttgart Mobile +49 176 196 32 406 Office +49 711 6 20 30 406 christian.giamba...@excelsisnet.com www.excelsisnet.com Sitz Stuttgart Amtsgericht Stuttgart, HRB 21104 Geschäftsführer: Christian Sauter, Dr. Nils Herda, Frank Wolf -Ursprüngliche Nachricht- Von: Martin Grigorov [mailto:mcgreg...@e-card.bg] Gesendet: Montag, 5. Oktober 2009 15:56 An: users@wicket.apache.org Betreff: Re: Send file to client via Ajax why do you want to use AjaxFallbackButton ? you will not re-paint part of the page use ResourceLink to download the file El lun, 05-10-2009 a las 15:36 +0200, Giambalvo, Christian escribió: > Hi all, > > simple question :) > > how to send a dynamicly generated file (as byte array) through an > ajaxfallbackbutton tot he client? > > > Mit freundlichen Grüßen > Christian Giambalvo > -- > Fachinformatiker für Anwendungsentwicklung > > EXCELSIS Informationssysteme GmbH > Wilhelmsplatz 8 - 70182 Stuttgart > Mobile +49 176 196 32 406 > Office +49 711 6 20 30 406 > christian.giamba...@excelsisnet.com > www.excelsisnet.com > > Sitz Stuttgart > Amtsgericht Stuttgart, HRB 21104 > Geschäftsführer: Christian Sauter, Dr. Nils Herda, Frank Wolf - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Send file to client via Ajax
why do you want to use AjaxFallbackButton ? you will not re-paint part of the page use ResourceLink to download the file El lun, 05-10-2009 a las 15:36 +0200, Giambalvo, Christian escribió: > Hi all, > > simple question :) > > how to send a dynamicly generated file (as byte array) through an > ajaxfallbackbutton tot he client? > > > Mit freundlichen Grüßen > Christian Giambalvo > -- > Fachinformatiker für Anwendungsentwicklung > > EXCELSIS Informationssysteme GmbH > Wilhelmsplatz 8 - 70182 Stuttgart > Mobile +49 176 196 32 406 > Office +49 711 6 20 30 406 > christian.giamba...@excelsisnet.com > www.excelsisnet.com > > Sitz Stuttgart > Amtsgericht Stuttgart, HRB 21104 > Geschäftsführer: Christian Sauter, Dr. Nils Herda, Frank Wolf - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Send file to client via Ajax
Hi all, simple question :) how to send a dynamicly generated file (as byte array) through an ajaxfallbackbutton tot he client? Mit freundlichen Grüßen Christian Giambalvo -- Fachinformatiker für Anwendungsentwicklung EXCELSIS Informationssysteme GmbH Wilhelmsplatz 8 - 70182 Stuttgart Mobile +49 176 196 32 406 Office +49 711 6 20 30 406 christian.giamba...@excelsisnet.com www.excelsisnet.com Sitz Stuttgart Amtsgericht Stuttgart, HRB 21104 Geschäftsführer: Christian Sauter, Dr. Nils Herda, Frank Wolf