You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-dev@jakarta.apache.org by ma...@apache.org on 2004/01/29 07:18:11 UTC

cvs commit: jakarta-taglibs/mailer/xml mailer.xml

martinc     2004/01/28 22:18:11

  Modified:    mailer/src/org/apache/taglibs/mailer MailTag.java
                        MessageTag.java SendTag.java
               mailer/xml mailer.xml
  Log:
  Add a new 'charset' attribute to the <message> tag, to allow the explicit
  addition of a character set to the content type.
  
  PR: 23858
  Submitted by: Bin Sun (sun2bin at 163.com)
  
  Revision  Changes    Path
  1.11      +28 -3     jakarta-taglibs/mailer/src/org/apache/taglibs/mailer/MailTag.java
  
  Index: MailTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/mailer/src/org/apache/taglibs/mailer/MailTag.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- MailTag.java	29 Jan 2004 05:19:26 -0000	1.10
  +++ MailTag.java	29 Jan 2004 06:18:11 -0000	1.11
  @@ -215,6 +215,11 @@
       private String type = "text/plain";
   
       /**
  +     * character set (default is unspecified)
  +     */
  +    private String charset = null;
  +
  +    /**
        * jndi name for Session object
        */
       private String session = null;
  @@ -577,6 +582,16 @@
       }
   
       /**
  +     * get the character set for this email
  +     *
  +     * @return -  string that is the character set for this email
  +     *
  +     */
  +    public final String getCharset() {
  +	return charset;
  +    }
  +
  +    /**
        * set true if error has occured
        *
        * @param value  value that determines if an error has occured
  @@ -768,6 +783,16 @@
   	    type = "text/html";
   	else
   	    type = "text/plain";
  +    }
  +
  +    /**
  +     * set the character set for this email
  +     *
  +     * @param value  string that is the character set for this email
  +     *
  +     */
  +    public final void setCharset(String value) {
  +        charset = value;
       }
   
       /**
  
  
  
  1.7       +24 -3     jakarta-taglibs/mailer/src/org/apache/taglibs/mailer/MessageTag.java
  
  Index: MessageTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/mailer/src/org/apache/taglibs/mailer/MessageTag.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- MessageTag.java	3 Dec 2002 16:08:19 -0000	1.6
  +++ MessageTag.java	29 Jan 2004 06:18:11 -0000	1.7
  @@ -79,6 +79,11 @@
    *            <required>false</required>
    *            <rtexprvalue>false</rtexprvalue>
    *      </attribute>
  + *      <attribute>
  + *            <name>charset</name>
  + *            <required>false</required>
  + *            <rtexprvalue>false</rtexprvalue>
  + *      </attribute>
    * </tag>
    *
    * @author Rich Catlett
  @@ -95,6 +100,11 @@
       private String type = "text";
   
       /**
  +     * character set to be used (default is unspecified)
  +     */
  +    private String charset = null;
  +
  +    /**
        *  implementation of the method from the tag interface that tells the JSP
        *  page what to do after the body of this tag
        *
  @@ -122,6 +132,7 @@
           }
   	myparent.setMessage(message); // set message in the parent tag
   	myparent.setType(type);  // set the mime type of the message
  +	myparent.setCharset(charset);  // set the character set of the message
   	return SKIP_BODY;
       }
   
  @@ -133,5 +144,15 @@
        */
       public final void setType(String value) {
   	type = value;
  +    }
  +
  +    /**
  +     * set the character set for this email
  +     *
  +     * @param value  string that is the character set for this email
  +     *
  +     */
  +    public final void setCharset(String value) {
  +	charset = value;
       }
   }
  
  
  
  1.15      +21 -5     jakarta-taglibs/mailer/src/org/apache/taglibs/mailer/SendTag.java
  
  Index: SendTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/mailer/src/org/apache/taglibs/mailer/SendTag.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- SendTag.java	3 Dec 2002 16:08:19 -0000	1.14
  +++ SendTag.java	29 Jan 2004 06:18:11 -0000	1.15
  @@ -353,7 +353,7 @@
   		MimeBodyPart mbp = new MimeBodyPart();
   
   		// set the content in the bodypart 
  -		mbp.setContent(myparent.getBody(), myparent.getType());
  +		mbp.setContent(myparent.getBody(), getContentType(myparent));
   
   		// add the message as the first bodypart in the multipart object
   		multipart.addBodyPart(mbp);
  @@ -380,7 +380,7 @@
   	} else {
   	    try {
   		// set the message with a mimetype according to type set by user
  -		message.setContent(myparent.getBody(), myparent.getType());
  +		message.setContent(myparent.getBody(), getContentType(myparent));
   	    } catch (MessagingException me) {
   		// this error is not very likely to occur
   		throw new JspException("The message could not be set in " +
  @@ -438,6 +438,22 @@
        */
       public final ArrayList getError() {
           return error;
  +    }
  +
  +    /**
  +     * get the content type, possibly including character set
  +     *
  +     * @return - complete encoded content type
  +     */
  +    public String getContentType(MailTag parent) {
  +        String type = parent.getType();
  +        String charset = parent.getCharset();
  +
  +        if (charset == null) {
  +            return type;
  +        }
  +
  +        return type + ";charset=" + charset;
       }
   }
   
  
  
  
  1.13      +12 -1     jakarta-taglibs/mailer/xml/mailer.xml
  
  Index: mailer.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/mailer/xml/mailer.xml,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- mailer.xml	29 Jan 2004 05:19:26 -0000	1.12
  +++ mailer.xml	29 Jan 2004 06:18:11 -0000	1.13
  @@ -445,7 +445,18 @@
   	    selected the body of the message is just plain text (it has no html 
   	    tags within it). If html is selected then the body of the message 
   	    can contain HTML tags. The default value for this attribute is text.
  -	</description>
  +        </description>
  +        <availability>1.0</availability>
  +      </attribute>
  +      <attribute>
  +        <name>charset</name>
  +        <required>no</required>
  +        <rtexprvalue>no</rtexprvalue>
  +        <description>
  +        This attribute specifies the character set of the message. If this
  +        attribute is not specified, no value will be included with the type
  +        of the message, leaving the default in place.
  +        </description>
           <availability>1.0</availability>
         </attribute>
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-dev-help@jakarta.apache.org