-
1. Re: Mapping URL's to a seam actions.
gavin.king Mar 31, 2006 4:39 AM (in response to markfrench)What exactly do you mean? That was not enough information...
-
2. Re: Mapping URL's to a seam actions.
markfrench Apr 2, 2006 6:11 PM (in response to markfrench)Basically the current ui makes a request to a cgi script for images and passes in some data. The script then returns image stream can this be replicated in seam. For example open url : localhost/images.cgi?id=1233. Hope this makes sense as I'm trying to avoid writing a servlet just for this purpose.
-
3. Re: Mapping URL's to a seam actions.
eekboom Apr 3, 2006 4:17 AM (in response to markfrench)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); } }
-
4. Re: Mapping URL's to a seam actions.
markfrench Apr 4, 2006 2:38 AM (in response to markfrench)Hi,
Thanks for that thats part of the puzzle I'm just not sure map a specific URL
e.g. /ui/loadImage.cgi to always hit the action. Is possible using the faces-config.xml file or web.xml?
Cheers
Mark -
5. Re: Mapping URL's to a seam actions.
gavin.king Apr 4, 2006 4:49 AM (in response to markfrench)Use a Seam page action (this functionality is only in CVS).
<pages> <page view-id="/ui/loadImage.jsp" action="#{my.action}"/> </pages>
-
6. Re: Mapping URL's to a seam actions.
chrholm May 1, 2006 5:51 AM (in response to markfrench)Would it be possible to enhance SEAM to use annotations to achieve this? It would be very nice if you could annotate your ejb method with something like
@Page("/home.faces")