I am not sure if this is what you are after.
Anyway here's a seam action I wrote to serve pdf files and avoid writing a
servlet.
I guess you should be able to simply change to other mime types like images.
@Stateless(name = "ReportAction")
| @Name("_reportAction")
| @Interceptors(SeamInterceptor.class)
| @Local(ReportAction.class)
| public class ReportActionImpl implements ReportAction {
| @In("facesContext")
| private transient FacesContext _facesContext;
|
| @In(create = true)
| private ReportGenerator _reportGenerator;
|
| public String generateUserReport() {
| return generatePdfReport("http://foo.jrxml", "foo.pdf");
| }
|
| private String generatePdfReport(String urlText, String fileName) {
| try {
| ExternalContext external = _facesContext.getExternalContext();
| HttpServletResponse response = (HttpServletResponse)
external.getResponse();
|
| URL url = new URL(urlText);
| byte[] data = _reportGenerator.generatePdfReport(url);
|
| configureResponse(response, fileName, data.length);
|
| ServletOutputStream out = response.getOutputStream();
| out.write(data);
| out.flush();
| _facesContext.responseComplete();
|
| return null;
| }
| catch(IOException e) {
| throw new RuntimeException("Cannot generate report: ", e);
| }
| }
|
| private void configureResponse(HttpServletResponse response, String
fileName, int length) {
| response.setHeader("Expires", "0");
| response.setHeader("Cache-Control", "must-revalidate,
post-check=0, pre-check=0");
| response.setHeader("Pragma", "public");
| response.setContentType("application/pdf");
| response.addHeader("Content-disposition", "attachment; filename=\""
+ fileName +"\"");
| response.setContentLength(length);
| }
| }
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3934261#3934261
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3934261
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user