You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.
| Online: | 9 Members of 4089 |
| Forum: Seam Users |
02. Jun 2008, 21:46 CET | Link |
Good Afternoon, All:
I am looking for code examples that will allow me to use SEAM to generate PDF files that I can save to the server instead of rendering to a web browser.
In brief, when the user has completed a process of entering data on the website, I would like to generate a PDF that I can store on the file server. (This PDF will eventually be printed and stuffed in an envelope along with appropriate pamphlets and other data, to be snail mailed
to the user in response to their online request.)
It appears that the ability to generate PDF files in SEAM that can be saved to a server instead of being sent to a browser is a future enhancement for SEAM. In the meantime, I need a solution more immediately.
Has there been any code developed that can handle this type of request until this is added as a new feature in a future release of SEAM?
If no code exists, if anyone has any suggestions that I could pursue in developing my own code to meet this need, please feel free to offer your advice here.
With Regards,
Jason Flynn
Kemp
Hello Jason,
I never did that myself, but one suggestion is to check Seam's source code to find out how the Renderer component actually renders content (Renderer is used to send emails -- see Seam docu ch 17). I just checked it myself, and actually it doesn't look too complicated. Check the file jboss-seam-2.0.1.GA/ui/src/main/java/org/jboss/seam/ui/facelet/FaceletsRenderer.java
You probably could use it as an example on how to render something to a file. Line 104 shows how you could pass a FileWriter.
Or... it seems like you will process those PDFs in batch, so another suggestion is to create a simple script that uses wget to fetch the PDF from a given URL and store it in a given directory. It's definitely not a pretty solution, but it might work for you. Alternatively, you could use some Java-based HTTP client to accomplish the same.
Hi Jason,
See my post here!
Cheers- Ben
Ben,
In reviewing your code, I can see that the first section stands alone as its own class. I assume that I will need to add the appropriate imports, but the basics are there.
Now, as for the second section of code, I assume that this (or something like it) could be added to my manager bean for the processing of these requests after the user submits their information via the web UI. Using the PDF XHTML file I've created, this code will presumably generate the PDF and store it as a byte array under the variable named data. We cast it as a byte array into the bytes variable, and presumably from there, I can save the file to the server from the bytes variable.
Do I understand that correctly? Or is there more to this picture that I'm missing?
With Regards, Jason Kemp
You got it :)
Now, if I could only get conversation to resolve, I'd be happy. I thought it was implicitly called out in Seam as a variable, but for whatever reason, Eclipse doesn't recognize it so it isn't compiling. :(
I'm still digging away at it, though, Jason
There's an open JIRA, JBSEAM-2613, for this. If anyone has specific suggestions or usecases, it might be helpful to comment there.