Download of text file created on the fly, repeat problem
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