Hi Derek,
Here is what I use:
<map:match pattern="saveToMyComputer">
<map:act type="set-header">
<map:parameter
name="Content-Disposition"
value="attachment ; filename=dataBenchResult-{request-param:resultNum}.xml"
/>
<map:generate type="tool-session-info" src="dataBenchResults">
<map:parameter name="number"
value="{request-param:resultNum}"/>
</map:generate>
<map:transform src="styles/result2xml.xsl"/>
<map:serialize type="xml"/>
</map:act>
</map:match>
In this pipeline, tool-session-info is a custom made generator, but you can replace it with any other generator. I don't set content type anywhere as it's not necessary (that was mentioned in some of the previous posts). If you really need this, you can add a new serializer configuration, where for mime-type attribute, there will be "application/x-download":
<map:serializers default="html">
<map:serializer
logger="sitemap.serializer.xml"
mime-type="application/x-download" name="xml-download"
src="org.apache.cocoon.serialization.XMLSerializer"/>
</map:serializers>I haven't tried that, but I also believe that you should be able to get these settings changed from flow.
Thank you. Sincerely, Nick.
Derek Hohls wrote:
Followup:
In the article quoted previously: http://www.onjava.com/pub/a/onjava/excerpt/jebp_3/index3.html
the code for setting content type and disposition are given as: res.setContentType("application/x-download"); res.setHeader("Content-Disposition", "attachment; filename=" + filename);
Can someone provide a simple example of how this would look in Cocoon for a dynamically generated file? Are the above settings provided in the sitemap - if so how? If not, where else?
Thanks Derek.
[EMAIL PROTECTED] 2005/02/26 10:07:57 PM >>>
Nick Goupinets wrote:
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);
}
}
This is also a good idea. As long as you do not have to support
browsers that restrict javascript functions that can be run.
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
