You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Gary Larsen <ga...@envisn.com> on 2007/02/09 15:16:19 UTC

Serialize to file?

I can't say I get all the pipeline concepts yet so excuse be if I'm missing
something simple.

Right now I only use the HTML serializer, but want to provide options in the
app to use both the Text and HSSF serializers.

Is is possible to configure the sitemap or serializer to 'save to file' and
prompt the user with a SaveAs dialog?

If not, is the standard approach to send output the the browser as normal
and rely on the browser's menu options?

Thanks,
Gary  


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


RE: Serialize to file?

Posted by Gary Larsen <ga...@envisn.com>.
 
Thanks Geert.  This helps me understand actions a bit more also!

Gary

>       <map:match pattern="download-*-zip">
>         <map:generate src="cocoon:/generate-{1}-zip"/>
> 
>         <map:act type="set-header">
>           <map:parameter name="Content-Type"
> value="application/x-download"/>
>           <map:parameter name="Content-Disposition" 
> value="attachment ; filename={1}.zip"/>
> 
>           <map:serialize type="zip"/>
>         </map:act>
>       </map:match> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


RE: Serialize to file?

Posted by Gary Larsen <ga...@envisn.com>.
I have another question on this.

I'm able to get the browser to prompt to save a file:

>       <map:match pattern="download-*-zip">
>         <map:generate src="cocoon:/generate-{1}-zip"/>
> 
>         <map:act type="set-header">
>           <map:parameter name="Content-Type"
> value="application/x-download"/>
>           <map:parameter name="Content-Disposition" value="attachment ;
> filename={1}.zip"/>
> 
>           <map:serialize type="zip"/>
>         </map:act>
>       </map:match>

I'm using a sendPage from flow to hit the matcher after displaying the form.
After the browser file save (or cancel) the form is still displayed.

Is there some way to redirect after the serializer in the matcher?  I tried
adding a redirect before </map:match> but it did not work:

<map:redirect-to uri="cocoon:/homeNav"/>

I hope that makes sense,
Gary


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


RE: Serialize to file?

Posted by Geert Josten <ge...@daidalos.nl>.
I typically use the following, though there are other solutions
possible:

      <map:match pattern="download-*-zip">
        <map:generate src="cocoon:/generate-{1}-zip"/>

        <map:act type="set-header">
          <map:parameter name="Content-Type"
value="application/x-download"/>
          <map:parameter name="Content-Disposition" value="attachment ;
filename={1}.zip"/>

          <map:serialize type="zip"/>
        </map:act>
      </map:match> 

Other serializers are possible ofcourse.. :-)

HTH,
Geert

> 
   
 
Drs. G.P.H. Josten
Consultant
 
 

Daidalos BV
Source of Innovation
Hoekeindsehof 1-4
2665  JZ  Bleiswijk
Tel.: +31 (0) 10 850 1200
Fax: +31 (0) 10 850 1199
www.daidalos.nl
KvK 27164984


De informatie - verzonden in of met dit emailbericht - is afkomstig van Daidalos BV en is uitsluitend bestemd voor de geadresseerde. Indien u dit bericht onbedoeld hebt ontvangen, verzoeken wij u het te verwijderen. Aan dit bericht kunnen geen rechten worden ontleend.
 

> Van: Gary Larsen [mailto:gary.larsen@envisn.com] 
> Verzonden: vrijdag 9 februari 2007 17:02
> Aan: users@cocoon.apache.org
> Onderwerp: RE: Serialize to file?
> 
> Hi Jeroen,
> 
> Thanks for your advice and pointers.  I'll give these a try.
> 
> Gary
> 
> > You could try to set the content-type of the serializer to a type 
> > which is not recognized by the browser. For instance:
> > 
> > "application/x-download" or "application/x-unknown"
> > 
> > Next to that you can use an sitemap action or something 
> equivalent to 
> > send an header to the browser:
> > 
> > ("Content-Disposition", "attachment; filename=myfile.extension")
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


RE: Serialize to file?

Posted by Gary Larsen <ga...@envisn.com>.
Hi Jeroen,

Thanks for your advice and pointers.  I'll give these a try.

Gary

> You could try to set the content-type of the serializer to a 
> type which is not recognized by the browser. For instance:
> 
> "application/x-download" or "application/x-unknown"
> 
> Next to that you can use an sitemap action or something 
> equivalent to send an header to the browser:
> 
> ("Content-Disposition", "attachment; filename=myfile.extension")
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Serialize to file?

Posted by Jeroen Reijn <j....@hippo.nl>.
Hi Gary,

i'll try to help you out.

Gary Larsen wrote:
> I can't say I get all the pipeline concepts yet so excuse be if I'm missing
> something simple.
> 
> Right now I only use the HTML serializer, but want to provide options in the
> app to use both the Text and HSSF serializers.
> 
> Is is possible to configure the sitemap or serializer to 'save to file' and
> prompt the user with a SaveAs dialog?


Well this is more or less a browser issue. Most browsers second-guess 
the server directives and do what they think is best. The browsers look 
at the file extension and try to guess the incoming content. I don't 
think there is a 100% reliable way of manipulating the browser to popup 
the 'save as' dialog. At OnJava I found an page recently with a solution 
[1].

You could try to set the content-type of the serializer to a type which 
is not recognized by the browser. For instance:

"application/x-download" or "application/x-unknown"

Next to that you can use an sitemap action or something equivalent to 
send an header to the browser:

("Content-Disposition", "attachment; filename=myfile.extension")


> 
> If not, is the standard approach to send output the the browser as normal
> and rely on the browser's menu options?

Yes you can do that.

> 
> Thanks,
> Gary  

Your welcome!

Regards,

Jeroen Reijn

[1] http://www.onjava.com/pub/a/onjava/excerpt/jebp_3/index3.html

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org