Seems I'm late to the party, but nevermind. :-)
We're doing this, but with Submits, not ActionLinks.
*Page.tml:*
<t:form t:id="doReportsForm" action="reportsForm" target="_blank">
<t:submit t:id="content" value="Download Content Report" />
</t:form>
*Page.java:*
private StreamResponse response;
public StreamResponse onSubmit() {
return response;
}
void onSelectedFromContent() {
response = new FileDownloadStreamResponse("content.html",
"text/html",
/* get a stream from somewhere, depends on your needs */ );
}
*FileDownloadStreamResponse.java:*
public class FileDownloadStreamResponse implements StreamResponse {
private String contentType;
private InputStream inputStream;
private String filename;
public FileDownloadStreamResponse(String filename, String contentType,
InputStream inputStream) {
this.filename = filename;
this.contentType = contentType;
this.inputStream = inputStream;
}
@Override
public String getContentType() {
return contentType;
}
@Override
public InputStream getStream() throws IOException {
return inputStream;
}
@Override
public void prepareResponse(Response response) {
response.setHeader("Content-Disposition", "attachment; filename="
+ filename);
}
}
Michael
On Fri, Mar 26, 2010 at 10:24 AM, Everton Agner
<[email protected]>wrote:
> Hi,
>
> I need to return a PDF file as response of a ActionLink request... How can
> I do that? Can I return a Resource or a File in the "onActionFromXXXX()"
> method and T5 takes care of the Response header configuration?
>
> Thanks!
>
>
>
>
>
> ____________________________________________________________________________________
> Veja quais são os assuntos do momento no Yahoo! +Buscados
> http://br.maisbuscados.yahoo.com
>