You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Dale Newfield <Da...@Newfield.org> on 2007/09/12 00:12:53 UTC

Re: [struts] setting the content disposition variable in a struts 2 action

Session A Mwamufiya wrote:
> I'm following the filedownload example from the showcase, but would
> like to be able to set the content disposition filename in my code,
> rather than have it hardcoded in the struts.xml file.

Just like any other result parameter, it can be set using OGNL 
(unfortunately delineated by "${}" instead of "%{}").

So try:
<param name="contentDisposition">${contentDisposition}</param>
and add a "public String getContentDisposition()" method to SMIGExport.

I really suggest adding a "contentLength" parameter, otherwise the 
framework may well have you generate the full content twice:  Once to 
determine the length, and again to send it.

> <param name="contentDisposition">savedName</param>

And keep in mind, the value for "contentDisposition" should not be a 
fileName, but rather a disposition (I.E. "inline" or "attachment"), 
which can subsequently take a filename argument.

Here's an example putting that all together:

<param 
name="contentDisposition">inline;filename="${media.code}.Media.${size}.${media.suffix}"</param>

-Dale

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org