cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Markus <t.mar...@proventis.net>
Subject Re: How to set filename of csv file
Date Wed, 01 Apr 2009 06:57:02 GMT
Hi,

sure you can. Set a special http-header. fi:

Content-Disposition: attachment; filename=MyFileName.csv

use attachment to force 'save as...' dialog or inline for default 
browser integration. filename has a special encoding. see 
http://www.ietf.org/rfc/rfc2231.txt and http://www.ietf.org/rfc/rfc2184.txt

regards
thomas

cocoon.erard@besonet.ch schrieb:
> Hello,
>
> in my application if a page, where a search can be performed and the 
> result is shown on the same page in form of a list.
>
> On the page, the user has a button (action widget) that returns him 
> the search result as a csv file. That's not a problem, this works. The 
> problem I have is the filename. The file is named as the current page 
> is. Somesing crypted with continuation id and .continue at die end. 
> Can I set the name of the file, the csv is serialized to the user?
>
> Here my current code:
>
> flowscript:
>
> list() {
>
>       //some code
>
>     
>       var form = new Form("pages/form/list_model.xml");
>       form.createBinding("pages/form/list_binding.xml");
>
>       while(true) {
>             form.load(to);
>             form.showForm("list.form", {
>                   itemList:itemList
>             });
>             form.save(to);
>            
>             var action = form.submitId;
>             if ("search".equals(action)) {
>                   itemList = 
> BridgeFactory.getInstance().getDummyBridge().search(context, to);
>             } else if ("resetButton".equals(action)) {
>                   to = new SearchTO();
>                   itemList = null;
>             } else if ("csv".equals(action)) {
>                   cocoon.sendPage("list.csv", {itemList:itemList});
>                   break;
>             }
>       }
> }
>
> sitemap:
>
> <map:serializer name="csv" mime-type="application/x-csv" 
> src="org.apache.cocoon.serialization.TextSerializer">
>     <encoding>ISO-8859-1</encoding>
>     <omit-xml-declaration>yes</omit-xml-declaration>
> </map:serializer>
>
>
> <map:match pattern="*.csv">
>    <map:generate src="pages/csv/{1}.csv"/>
>    <map:transform type="jx"/>
>    <map:transform src="stylesheets/csv.xsl" />
>    <map:transform type="dbi18n">
>       <map:parameter name="locale" value="{../locale}" />
>    </map:transform>
>    <map:serialize type="csv" />
> </map:match>
>
> Thanks,
>
> Mike

-- 
Thomas Markus

====================================================
proventis GmbH | Zimmerstr. 79-81 | D-10117 Berlin |
Tel +49 (0)30 2936399-22 | Fax -50 | t.markus@proventis.net
-----------------------------------------------------------------
Geschäftsführer: Norman Frischmuth | Sitz: Berlin
Handelsregister: AG Berlin-Charlottenburg, HR 82917
-----------------------------------------------------------------
Blue Ant-webbasiertes Projektmanagement - aktuelle Termine 2008:
http://www.proventis.net/website/live/blueant/veranstaltungen.html
====================================================


Mime
View raw message