Incidentally, when I woke up this morning, I was thinking about this exact same problem :)

In the case of an Ajax button, the request is from an XmlHttpRequest javascript (browser) object. I'm not sure if that even supports binary results (mime types other than text/xml and text/plain), but if it does you'd have to do something on the client side to show a download dialog or something.

A direction to a possible solution would be to respond with some kind of redirect to the URL of the binary (RequestCycle.urlFor(..)). Now your only problem is how to send a redirect over the XmlHttpRequest. Your best bet would be to send a little bit of javascript (window.location = "[url]"), or maybe there is a component for this already.

Good luck!
Matthijs

Martin Bednář wrote:
Hi,
I have problem when I use IndicatingAjaxSubmitButton for dowload after form submission.

I use this code, normal Button working correctly. it's bug in IndicatingAjaxSubmitButton or I'm doing something wrong ?

...

     //This dosn't work
       form.add(new IndicatingAjaxSubmitButton("submit", form) {
           @Override
protected void onSubmit(AjaxRequestTarget target, Form form) {
                processSubmit(); }
             });
         //This working
      form.add(new Button("submit") {
          @Override
          protected void onSubmit() {
              processSubmit();
          }
      });




private void processSubmit() {
      final String zipArchiveFilename = "/tmp/sample.zip";
      RequestCycle requestCycle = this.getRequestCycle();

final ResourceStreamRequestTarget exportTarget = new ResourceStreamRequestTarget(
              new FileResourceStream(new wicket.util.file.File(
                      zipArchiveFilename)), "application/zip") {
          @Override
          protected void configure(Response arg0, IResourceStream arg1) {
              super.configure(arg0, arg1);
              WebResponse response = (WebResponse) arg0;
              setFileName("sample.zip");
          }
      };

      requestCycle.setRequestTarget(exportTarget);
  }




--
Matthijs Wensveen
Func. Internet Integration
W http://www.func.nl
T +31 20 4230000
F +31 20 4223500

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to