Unfortunately I don't think this is going to work, Jesse. An intermediate format would be needed that encapsulates every piece of information in the JSF components in case it is needed - ie it will be just as complex as the component tree.
And this doesn't solve the "postback" phase. Currently the RenderKit approach ensures that a custom renderer object is provided to help decode the submitted data; that doesn't appear to exist in your suggestion. I'm sure the MyFaces team (and the JSF expert group) are open to new ideas but I don't currently see how this will work. It does sound rather similar to cocoon, which is excellent at publishing but doesn't have any complex "submit" handling as far as I know. Cheers, Simon On Tue, 2006-01-17 at 12:21 +0100, Jesse Alexander (KBSA 21) wrote: > Reading this thread I came up with this idea: > > Have the render-kit create a dom-representation of the UI-tree. > Then have a transform-mechanism convert it inot either html or pdf or wml, > or... > according to the useragents needs or according to some other request-settings > that control the finaldisposition of the output > > regards > Alexander > > ________________________________ > > From: Jurgen Lust [mailto:[EMAIL PROTECTED] > Sent: Tuesday, January 17, 2006 11:19 AM > To: MyFaces Discussion > Subject: Re: easiest way to get a jsf page as pdf download > > > I would definitely write pdf renderers for some components if other people > want to help... > > Jurgen > > Matthias Wessendorf schreef: > > Right Juergen! > > would you like to volunteer ? :-) > > SpringMVC has some *pdf* based rendering stuff. > > -Matthias > > On 1/17/06, Jurgen Lust <[EMAIL PROTECTED]> <mailto:[EMAIL PROTECTED]> > wrote: > > > Theoretically, you could write a new RenderKit which renders a > JSF page to > PDF instead of HTML. It would probably even work with > AcroForms... > > Jurgen > > Simon Kitching schreef: > Hi Hans, > > What Matthias describes below is where you have a JSF page, and > you want > a button labelled "generate report" or similar that creates > some kind of > PDF document then serves it up to the user's browser. But that > PDF isn't > "a picture of the current page", it's a PDF generated using > data pulled > from a database or something like that. If that's really what > you are > after then FOP is a good tool for that; your java code creates > some xml > using the FO schema, then feeds it to the FOP library. Nothing > to do > with JSF though. > > There is no way to "generate a pdf that looks like my html > screen" from > java code which I believe is what you want to do. Some browsers > provide > a "print page" option, and some operating systems provide a > "print to > PDF" option in the print dialog so that's one way of creating a > PDF that > contains the current page but it's manual. > > The FOP project is here: > http://xmlgraphics.apache.org/fop/ > > Regards, > > Simon > > > > > On Tue, 2006-01-17 at 09:58 +0100, Hansjörg Meuschel wrote: > > > Hi Matthias, > > thanks for your help... a friend of mine also recommended FOP in > between. I took a look at the api but it seems to me that FOP > uses XML > to generate a PDF? ! > --> So how can I convert my jsf page into the required FOP-input > format?? I could not find any docu to fop (except some broken > links...) ? > > regards, > Hans > > > > Matthias Wessendorf wrote: > > > > Hansjoerg, > > we have worked with Apache FOP for creating pdfs. iText or > JasperReports are also lib that help you on that task. > > inside of your backing bean method (referenced by a commandLink > or > cmdButton) you can do somthing like this: > > public String pdf() { > > FacesContext ctx = FacesContext.getCurrentInstance(); > > if(!ctx.getResponseComplete()) { > > > HttpServletResponse response = (HttpServletResponse) > ctx.getExternalContext().getResponse(); > > byte[] file = //do some FOP, or ... stuff; > > response.setContentType("application/pdf"); > response.setHeader("Content-Disposition", "inline; > filename=\"foo.pdf\""); > response.setContentLength(file.length); > > OutputStream out = response.getOutputStream(); > out.write(file, 0, file.length); > out.flush(); > out.close(); > > ctx.responseComplete(); > > return null; > } > > > This will work in p(l)ain servlet or struts world too (expect > of the > usage of jsf api (like FacesContext)) > > However, the *magic* here is the responseComplete() > <from_java_doc> > Signal the JavaServer Faces implementation that the HTTP > response for > this request has already been generated (such as an HTTP > redirect), > and that the request processing lifecycle should be terminated > as soon > as the current phase is completed. > </from_java_doc> > > and yes... it's getResponseComplete() instead of > isResponseComplete() > > HTH, > Matthias > > > On 1/15/06, Hansjörg Meuschel <[EMAIL PROTECTED]> > <mailto:[EMAIL PROTECTED]> wrote: > > > > > Hi folks, > does anybody know what is the easiest way to get a jsf page as > pdf > download? Are there any libraries available for free? > > > > > -- > Matthias Wessendorf > Zülpicher Wall 12, 239 > 50674 Köln > http://www.wessendorf.net > mwessendorf-at-gmail-dot-com > > > > > > > > -- > Among flowers, the cherry blossom. > Among men, me. > > > > > > > > -- > Matthias Wessendorf > Zülpicher Wall 12, 239 > 50674 Köln > http://www.wessendorf.net > mwessendorf-at-gmail-dot-com > > > >

