[jboss-cvs] jboss-seam/src/mail/org/jboss/seam/mail/ui ...

Peter Muir peter at bleepbleep.org.uk
Thu Apr 5 11:08:26 EDT 2007


  User: pmuir   
  Date: 07/04/05 11:08:26

  Modified:    src/mail/org/jboss/seam/mail/ui     UIMessage.java
                        UIBody.java MailComponent.java UISubject.java
  Log:
  JBSEAM-1133 & JBSEAM-1134
  
  Revision  Changes    Path
  1.13      +1 -5      jboss-seam/src/mail/org/jboss/seam/mail/ui/UIMessage.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: UIMessage.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/mail/org/jboss/seam/mail/ui/UIMessage.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -b -r1.12 -r1.13
  --- UIMessage.java	22 Mar 2007 18:06:15 -0000	1.12
  +++ UIMessage.java	5 Apr 2007 15:08:26 -0000	1.13
  @@ -8,7 +8,6 @@
   import javax.mail.Multipart;
   import javax.mail.Session;
   import javax.mail.Transport;
  -import javax.mail.internet.InternetHeaders;
   import javax.mail.internet.MimeMessage;
   import javax.mail.internet.MimeMultipart;
   
  @@ -85,11 +84,8 @@
      @Override
      public void encodeBegin(FacesContext context) throws IOException
      {
  -      if (getUrlBase() != null)
  -      {
            MailFacesContextImpl.start(getUrlBase()
                     + context.getExternalContext().getRequestContextPath());
  -      }
         mimeMessage = null;
         try
         {
  
  
  
  1.10      +13 -9     jboss-seam/src/mail/org/jboss/seam/mail/ui/UIBody.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: UIBody.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/mail/org/jboss/seam/mail/ui/UIBody.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -b -r1.9 -r1.10
  --- UIBody.java	22 Mar 2007 18:06:15 -0000	1.9
  +++ UIBody.java	5 Apr 2007 15:08:26 -0000	1.10
  @@ -11,6 +11,8 @@
   import javax.mail.internet.MimeBodyPart;
   import javax.mail.internet.MimeMultipart;
   
  +import org.jboss.seam.mail.ui.context.MailResponseWriter;
  +
   /**
    * JSF component for rendering the body Supports plain text, html bodies and
    * setting an alternative (text) part using an alternative facet
  @@ -30,21 +32,22 @@
      {
         try
         {
  -         String body = encode(facesContext);
            BodyPart bodyPart = null;
            if (PLAIN.equalsIgnoreCase(type))
            {
  +            String body = encode(facesContext, MailResponseWriter.TEXT_PLAIN_CONTENT_TYPE);
               bodyPart = getTextBody(facesContext, body);
            }
            else if (HTML.equals(type))
            {
               UIComponent alternative = getFacet("alternative");
  +            String body = encode(facesContext, MailResponseWriter.HTML_PLAIN_CONTENT_TYPE);
               if (alternative != null)
               {
                  Multipart multipart = new MimeMultipart("alternative");
   
                  multipart.addBodyPart(getTextBody(facesContext, encode(facesContext,
  -                        alternative)));
  +                        alternative, MailResponseWriter.TEXT_PLAIN_CONTENT_TYPE)));
                  multipart.addBodyPart(getHtmlBody(facesContext, body));
   
                  bodyPart = new MimeBodyPart();
  @@ -81,20 +84,21 @@
         return type;
      }
   
  -   private BodyPart getTextBody(FacesContext facesContext, Object body)
  +   private BodyPart getTextBody(FacesContext facesContext, String body)
               throws MessagingException
      {
  -      BodyPart bodyPart = new MimeBodyPart();
  +      MimeBodyPart bodyPart = new MimeBodyPart();
         bodyPart.setDisposition("inline");
         String charset = findMessage().getCharset();
         if ( charset != null) 
         {
  -         bodyPart.setContent(body, "text/plain; charset="
  -               + charset + "; format=flowed");
  +         //bodyPart.setContent(body, "text/plain; charset="
  +         //      + charset + "; format=flowed");
  +         bodyPart.setText(body, charset);
         } 
         else 
         {
  -         bodyPart.setContent(body, "text/plain");
  +         bodyPart.setText(body);
         }
         return bodyPart;
      }
  @@ -102,7 +106,7 @@
      private BodyPart getHtmlBody(FacesContext facesContext, Object body)
               throws MessagingException
      {
  -      BodyPart bodyPart = new MimeBodyPart();
  +      MimeBodyPart bodyPart = new MimeBodyPart();
         bodyPart.setDisposition("inline");
         String charset = findMessage().getCharset();
         if ( charset != null) 
  
  
  
  1.7       +91 -57    jboss-seam/src/mail/org/jboss/seam/mail/ui/MailComponent.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: MailComponent.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/mail/org/jboss/seam/mail/ui/MailComponent.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -b -r1.6 -r1.7
  --- MailComponent.java	22 Mar 2007 18:06:15 -0000	1.6
  +++ MailComponent.java	5 Apr 2007 15:08:26 -0000	1.7
  @@ -11,6 +11,7 @@
   import javax.mail.internet.MimeMessage;
   import javax.mail.internet.MimeMultipart;
   
  +import org.jboss.seam.mail.ui.context.MailResponseWriter;
   import org.jboss.seam.ui.JSF;
   
   /**
  @@ -33,23 +34,35 @@
      }
      
      @Override
  -   public boolean getRendersChildren() {
  +   public boolean getRendersChildren()
  +   {
          return true;
      }
      
  -   
  -   protected String encode(FacesContext facesContext) throws IOException {
  +   protected String encode(FacesContext facesContext) throws IOException
  +   {
        return encode(facesContext, this);
      }
      
  +   protected String encode(FacesContext facesContext, UIComponent cmp) throws IOException
  +   {
  +      return encode(facesContext, cmp, null);
  +   }
  +   
  +   protected String encode(FacesContext facesContext, String contentType) throws IOException
  +   {
  +      return encode(facesContext, this, contentType);
  +   }
  +
      /**
  -    * Encode the children of cmp, writing to a string (rather than the http response object)
  -    * and return the string
  +    * Encode the children of cmp, writing to a string (rather than the http
  +    * response object) and return the string
       */
  -   protected String encode(FacesContext facesContext,UIComponent cmp) throws IOException {
  +   protected String encode(FacesContext facesContext, UIComponent cmp, String contentType) throws IOException
  +   {
         ResponseWriter response = facesContext.getResponseWriter();
         StringWriter stringWriter = new StringWriter();
  -      ResponseWriter cachingResponseWriter = response.cloneWithWriter(stringWriter);
  +      ResponseWriter cachingResponseWriter = ((MailResponseWriter) response).cloneWithWriter(stringWriter, contentType);
         facesContext.setResponseWriter(cachingResponseWriter);
         JSF.renderChildren(facesContext, cmp);
         facesContext.setResponseWriter(response);
  @@ -59,16 +72,19 @@
      
      /**
       * look up the tree for mail message
  +    * 
       * @throws MessagingException 
       */
  -   public MimeMessage findMimeMessage() throws MessagingException {
  +   public MimeMessage findMimeMessage() throws MessagingException
  +   {
         return findMessage().getMimeMessage();
      }
      
      /**
       * look up the tree for UIMessage
       */
  -   public UIMessage findMessage() {
  +   public UIMessage findMessage()
  +   {
         if (message == null)
         {
             message = (UIMessage) findParent(this, UIMessage.class);
  @@ -80,18 +96,21 @@
         return message;
      }
      
  -   public MimeMultipart getRootMultipart() throws IOException, MessagingException  {
  +   public MimeMultipart getRootMultipart() throws IOException, MessagingException
  +   {
         return (MimeMultipart) findMimeMessage().getContent();
      }
      
  -   public MailComponent findParent(UIComponent parent) {
  +   public MailComponent findParent(UIComponent parent)
  +   {
         return findParent(parent, null);
      }
   
      /**
       * find the first parent that is a mail component of a given type
       */
  -   public MailComponent findParent(UIComponent parent, Class<?> c) {
  +   public MailComponent findParent(UIComponent parent, Class<?> c)
  +   {
          if (parent == null) 
          {
              return null;
  @@ -99,22 +118,26 @@
          
          if (parent instanceof MailComponent) 
          {
  -           if (c==null || c.isAssignableFrom(parent.getClass())) 
  +         if (c == null || c.isAssignableFrom(parent.getClass()))
              {
                  return (MailComponent) parent;
              }
          }
   
  -       return findParent(parent.getParent(),c);
  +      return findParent(parent.getParent(), c);
      }
      
      /**
       * Get a valuebinding as a string
       */
  -   protected String getString(String localName) {
  -      if (getValue(localName) != null) {
  +   protected String getString(String localName)
  +   {
  +      if (getValue(localName) != null)
  +      {
            return getValue(localName).toString();
  -      } else {
  +      }
  +      else
  +      {
            return null;
         }
      }
  @@ -122,10 +145,14 @@
      /**
       * Get a vauebinding
       */
  -   protected Object getValue(String localName) {
  -      if (getValueBinding(localName) == null) {
  +   protected Object getValue(String localName)
  +   {
  +      if (getValueBinding(localName) == null)
  +      {
            return null;
  -      } else {
  +      }
  +      else
  +      {
            return getValueBinding(localName).getValue(getFacesContext());
         }
      }
  @@ -133,15 +160,22 @@
      /**
       * Get a valuebinding as a Boolean 
       */
  -   protected Boolean getBoolean(String localName) {
  +   protected Boolean getBoolean(String localName)
  +   {
         Object o = getValue(localName);
  -      if (o != null) {
  -         if (o instanceof Boolean) {
  +      if (o != null)
  +      {
  +         if (o instanceof Boolean)
  +         {
               return (Boolean) o;
  -         } else {
  +         }
  +         else
  +         {
               return Boolean.valueOf(o.toString());
            }
  -      } else {
  +      }
  +      else
  +      {
            return null;
         }
      }
  
  
  
  1.4       +3 -1      jboss-seam/src/mail/org/jboss/seam/mail/ui/UISubject.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: UISubject.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/mail/org/jboss/seam/mail/ui/UISubject.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- UISubject.java	22 Mar 2007 18:06:15 -0000	1.3
  +++ UISubject.java	5 Apr 2007 15:08:26 -0000	1.4
  @@ -6,6 +6,8 @@
   import javax.faces.context.FacesContext;
   import javax.mail.MessagingException;
   
  +import org.jboss.seam.mail.ui.context.MailResponseWriter;
  +
   /**
    * JSF component for rendering subject line
    */
  @@ -16,7 +18,7 @@
      {
         try
         {
  -         String subject = encode(facesContext);
  +         String subject = encode(facesContext, MailResponseWriter.TEXT_PLAIN_CONTENT_TYPE);
            String charset = findMessage().getCharset();
            if (charset == null)
            {
  
  
  



More information about the jboss-cvs-commits mailing list