cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthias Müller <>
Subject AW: [C2.2] Original name of uploaded file
Date Tue, 19 Apr 2011 07:47:36 GMT
I am using a fileupload widget and flowscript.
My flow function looks like that:

function myTask() {
    var form = new Form(cocoon.parameters["definitionURI"]);
    var file = form.getChild("uploadFile");
    var viewData = { "filename" : file.getValue() + ".pdf" };
    cocoon.sendPage("myTask.pdf", viewData);

In the sitemap.xmap I do the fo transformation and renaming:

<map:match pattern="myTask.pdf">
      <map:generate type="file" src="upload://uploadFile"/>
      <map:transform type="xslt-saxon" src="stylesheets/toFO.xsl" />
      <map:act type="set-header">
              <map:parameter name="Content-Type" 
              <map:parameter name="Content-Disposition" value="attachment ; 
      <map:serialize type="fo2pdf"/>

The only problem is that i receive the full path (value of the upload widget) 
instead of the name of the uploaded file.

How and where (flow script / sitemap) do i need to resolve the filename? The 
getValue() method seems to only return the widgets value. Do I need to cast the 
form.getChild("uploadFile") to org.apache.cocoon.servlet.multipart.Part instead? 
How can I achieve that?

Thanks, Matthias

----- Ursprüngliche Mail ----
Von: Thomas Markus <>
Gesendet: Dienstag, den 19. April 2011, 7:47:42 Uhr
Betreff: Re: [C2.2] Original name of uploaded file


when using a fileupload widget your value is of type 
It contains upload filename and content


Am 18.04.2011 14:46, schrieb Matthias Müller:
> Hi there,
> in my cocoon app i have a simple transformation xml ->  fo ->  pdf. The 
> pdf needs to be named as the uploaded xml file + .pdf extension.
> How can I achieve that? Is there a way to access the data of the uploaded file
> in the sitemap.xmap / flow.js?
> Matthias
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message