-
1. Re: Accessing generated PDFs
pmuir Feb 2, 2007 4:53 PM (in response to pmuir)So, for emails, this is my suggestion as to how you should be able to attach PDFs to the email:
<m:message> ... <m:attachment> <p:document> ... </p:document> </m:attachment> </m:message>
Of curse with this you would be able to use all the standard facelets templating stuff (ui:include being the one that springs to mind).
As for implementation I would guess something like:
UIAttachmentencodeBegin() { // If the attachment element contains a document element documentComponent.setRedirect(false); } encodeEnd() { // If the attachment element contains a document element InputStream is = documentComponent.getPdf(); String name = documentComponent.getName(); // Deal with attaching the InputStream }
I write this tho' with no idea of the feasability of doing that with the jboss-seam-pdf ;)
There are some other problems with embedding/attaching images to emails (generally you want to display them inline as part of your html body than attach them). -
2. Re: Accessing generated PDFs
norman.richards Feb 2, 2007 6:28 PM (in response to pmuir)What about a new <p:embeddedDocument> tag? (ok - we need a better name) This would be a subclass of UIDocument and replace the <p:document> tag only performing PDF creation portion. Actually, if I create that component then you could also register it as <m:document> to provide a nice local name.
-
3. Re: Accessing generated PDFs
norman.richards Feb 2, 2007 6:33 PM (in response to pmuir)The alternative is to keep <p:document> as the component that builds a PDF, and require it to be surrounded by something else like <p:saveAndRedirect> or <m:attachment>. This would break existing PDF usage, but since the functionality is so new I don't think it would cause our early adopters too much grief to have to add a new tag.
-
4. Re: Accessing generated PDFs
pmuir Feb 2, 2007 6:54 PM (in response to pmuir)Hmm - I like the idea of just being able to drop a p:document tag (via a ui:include) into a m:attachment tag, it's simple and requires the user to do no wiring. This way the same facelet could be used both in emails AND in the browser.
So I'm -1 on p:embeddedDocument atm
I prefer the p:saveAndRedirect approach but I guess my preferred route is to keep p:document, have it do a saveAndRedirect by default, unless told not to by a parent component. -
5. Re: Accessing generated PDFs
norman.richards Feb 2, 2007 9:12 PM (in response to pmuir)Ok, UIDocument now has a sendRedirect flag. If this is set (either in the template or by the parent component reaching down) we will bypass the the generation and just keep the value locally.
We needed some way to transfer the data. I noticed UIAttachment us using get/setValue. Assuming that it implemented ValueHolder, I thought I might reach up and set the values directly if I could. Unfortunately, I just realized you don't actually implement ValueHolder. I'm not sure this is proper use of ValueHolder anyway, so if you have a better idea, I'm all ears.
Also, note that you'll need to do your processing in encodeEnd() and not in encodeBegin(). The PDF won't available until UIDocument completes it's encodeEnd. -
6. Re: Accessing generated PDFs
pmuir Feb 3, 2007 4:05 PM (in response to pmuir)"norman.richards@jboss.com" wrote:
Ok, UIDocument now has a sendRedirect flag. If this is set (either in the template or by the parent component reaching down) we will bypass the the generation and just keep the value locally.
cool :)We needed some way to transfer the data. I noticed UIAttachment us using get/setValue. Assuming that it implemented ValueHolder, I thought I might reach up and set the values directly if I could. Unfortunately, I just realized you don't actually implement ValueHolder. I'm not sure this is proper use of ValueHolder anyway, so if you have a better idea, I'm all ears.
http://java.sun.com/javaee/javaserverfaces/1.1_01/docs/api/javax/faces/component/ValueHolder.html - I think that implementing ValueHolder here is a correct (I just hadn't) - there might be some interesting ways of using JSF Converters (though as they *have* to return a String when converting from the model to the view perhaps not) -
7. Re: Accessing generated PDFs
norman.richards Feb 3, 2007 4:23 PM (in response to pmuir)Let me know if you need anything else to make this work.
-
8. Re: Accessing generated PDFs
pmuir Feb 3, 2007 7:20 PM (in response to pmuir)Could there be a public accessor for docType to UIDocument so I can set the contentType for the attachment.
Also for baseName so that I can set the filename of the attachment -
9. Re: Accessing generated PDFs
norman.richards Feb 3, 2007 9:41 PM (in response to pmuir)org.jboss.seam.pdf.DocumentStore has an internal DocumentData class. I could move this out and use that structure as what I pass you, instead of just a byte[]. Do you think that would work better?
-
10. Re: Accessing generated PDFs
pmuir Feb 4, 2007 7:46 AM (in response to pmuir)That's probably neater.
-
11. Re: Accessing generated PDFs
norman.richards Feb 4, 2007 2:11 PM (in response to pmuir)Ok - done. You are now getting an org.jboss.seam.pdf.DocumentData.