• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Download of text file created on the fly, repeat problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Download of text file created on the fly, repeat problem


  • Subject: Download of text file created on the fly, repeat problem
  • From: Jon Kleiser <email@hidden>
  • Date: Thu, 21 Apr 2005 15:36:41 +0200

I have a page with a WOHyperlink that lets the user generate and download a text file, but my implementation has a weakness: The download method does not get called every second time the user clicks this link. It's probably got to do with "path ID" mismatch, but I don't know how to fix it. I'll describe my implementation ...

The download method just sets a flag, like this:

  public WOComponent download() {
    isDownloading = true;
    return this;
  }

The appendToResponse method delivers the text file and resets the flag:

public void appendToResponse(WOResponse resp, WOContext ctxt) {
if (isDownloading) {
String text = "test test test";
resp.setHeader("application/octet-stream", "content-type");
resp.setHeader("attachment; filename=\"test.txt\"", "content-disposition");
resp.setContent(text);
resp.setHeader(Integer.toString(text.length()), "content-length");
resp.disableClientCaching();
resp.removeHeadersForKey("Cache-Control");
resp.removeHeadersForKey("pragma");
isDownloading = false;
} else {
super.appendToResponse(resp, ctxt);
}
}


As long as the user don't try to download more than once, this works, but if he/she tries another download immediately after the first, nothing happens. (The download method doesn't get called the second time, but appendToResponse gets called.) I'll appreciate any ideas on how to fix it.

Jon Kleiser
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Download of text file created on the fly, repeat problem
      • From: Chuck Hill <email@hidden>
  • Prev by Date: anyone interested in sharing a WO server?
  • Next by Date: Re: ValidationException, need help
  • Previous by thread: anyone interested in sharing a WO server?
  • Next by thread: Re: Download of text file created on the fly, repeat problem
  • Index(es):
    • Date
    • Thread