Hi everybody,
Thank you very much for your support. The proposed solution was correct, the "SaveAs" dialog pops up with content disposition set up properly and the default mime type.
However, it appeared to be easier than expected to get the pop up from the browser. It is not necessary to open up a new window. It is sufficient to change current window location.href property (original window content remains unchanged):
function saveResult(){
var index = document.MyForm.SelectionBox.selectedIndex;
if (index == -1)
alert("Please make a selection first");
else {
window.location.href = 'coplets/myprojects/dataBench/saveResult?resultNum=' + index);
}
}
Thank you all once again.
Sincerely, Nick Goupinets.
Leszek Gawron wrote:
Nick Goupinets wrote:
Hi Kjell Arne,
Thank you very much for your reply. That was pretty quick :).
I don't think you will be able to save anything programatically to
the client machine from the browser.
Yes, I am aware of that, but thank you for reminding.
I know of only two options or workarounds. Either you have to instruct the
user to save the whole document from the file menu,
Oh, I wish the customer was that compassionate and understood the hardship of being a developer. :)
or you can use a Flash
swf or Java applet/program. At least you would have some possibility to save
to the client's hard disk.
This is not an option, as I don't think I am allowed to introduce any extra requirements to the browser (i.e. having flash/applet viewer installed).
Instead I wanted something like sourceforge downloads. You know when you click on "download" link, the same page is still displayed in the browser, but then a few seconds later "Save file" dialog box pops up, that lets you save the selected file to the disk (this sentence really gets me nailed, as it's not a Cocoon question - more like a JavaScript/browser one).
AFAIK such functionality can be accomplished by setting refresh meta tag in the header of the html page. It's "nice-and-easy", but I can't do that either, as what I am working on will be used in cocoon portal (which I think strips out all the html/head/body tags by default (for cachingURIcoplets), and it doesn't look right to hack the skin to allow for this one case).
So the problem are these:
1) which mime type needs to be selected for the serializer so that browser doesn't show the result but rather prompts to save it. Is it ok, if I put something that I know is not supported i.e.
<map:serialize
type="xml"
mime-type="application/my-not-supported-type"/>
You do not do it via mime-type but via an appropriate http header (Content-Disposition)
http://www.onjava.com/pub/a/onjava/excerpt/jebp_3/index3.html
still as the article say - you might have the problems with bad behaving browsers.
2) how to make sure that a new window is not opened, and the old one stays unchanged and the save-as dialog is still showed? (looks like an impossible task to me)
You need to open a new window. still you can provide some ways in client side JS to close it conveniently.
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
