[jboss-cvs] jboss-seam/src/mail/org/jboss/seam/mail/ui ...
Peter Muir
peter at bleepbleep.org.uk
Tue Aug 28 07:58:46 EDT 2007
User: pmuir
Date: 07/08/28 07:58:46
Modified: src/mail/org/jboss/seam/mail/ui UIAttachment.java
Log:
JBSEAM-1876
Revision Changes Path
1.9 +13 -9 jboss-seam/src/mail/org/jboss/seam/mail/ui/UIAttachment.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: UIAttachment.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/mail/org/jboss/seam/mail/ui/UIAttachment.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- UIAttachment.java 21 Jun 2007 04:07:13 -0000 1.8
+++ UIAttachment.java 28 Aug 2007 11:58:46 -0000 1.9
@@ -3,6 +3,7 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+import java.lang.reflect.Method;
import java.net.URL;
import javax.activation.DataHandler;
@@ -18,10 +19,9 @@
import javax.mail.internet.MimeBodyPart;
import javax.mail.util.ByteArrayDataSource;
-import org.jboss.seam.pdf.DocumentData;
-import org.jboss.seam.pdf.ui.UIDocument;
import org.jboss.seam.ui.util.JSF;
import org.jboss.seam.util.FacesResources;
+import org.jboss.seam.util.Reflections;
public class UIAttachment extends MailComponent implements ValueHolder
{
@@ -53,9 +53,10 @@
public void encodeBegin(FacesContext context) throws IOException
{
if (this.getChildCount() > 0) {
- if (this.getChildren().get(0) instanceof UIDocument) {
- UIDocument document = (UIDocument) this.getChildren().get(0);
- document.setSendRedirect(false);
+ if (Reflections.isInstanceOf(this.getChildren().get(0).getClass(), "org.jboss.seam.pdf.ui.UIDocument"))
+ {
+ Method method = Reflections.getSetterMethod(this.getChildren().get(0).getClass(), "sendRedirect");
+ Reflections.invokeAndWrap(method, this.getChildren().get(0), false);
JSF.renderChildren(context, this);
} else {
setValue(encode(context).getBytes());
@@ -93,10 +94,13 @@
InputStream is = (InputStream) getValue();
ds = new ByteArrayDataSource(is, getContentType());
}
- else if (getValue() instanceof DocumentData)
+ else if (Reflections.isInstanceOf(getValue().getClass(), "org.jboss.seam.pdf.DocumentData"))
{
- DocumentData documentData = (DocumentData) getValue();
- ds = new ByteArrayDataSource(documentData.getData(), documentData.getDocType().getMimeType());
+ Method dataGetter = Reflections.getGetterMethod(getValue().getClass(), "data");
+ Method docTypeGetter = Reflections.getGetterMethod(getValue().getClass(), "docType");
+ Object docType = Reflections.invokeAndWrap(docTypeGetter, getValue());
+ Method mimeTypeGetter = Reflections.getGetterMethod(docType.getClass(), "mimeType");
+ ds = new ByteArrayDataSource((byte[]) Reflections.invokeAndWrap(dataGetter, getValue()), (String) Reflections.invokeAndWrap(mimeTypeGetter, docType));
}
else if (getValue() != null && getValue().getClass().isArray())
{
More information about the jboss-cvs-commits
mailing list