View | Details | Raw Unified | Return to bug 23858
Collapse All | Expand All

(-)src/org/apache/taglibs/mailer/MailTag.java (+25 lines)
Lines 204-209 Link Here
204
    private String type = "text/plain";
204
    private String type = "text/plain";
205
205
206
    /**
206
    /**
207
     * character set (default is unspecified)
208
     */
209
    private String charset = null;
210
211
    /**
207
     * jndi name for Session object
212
     * jndi name for Session object
208
     */
213
     */
209
    private String session = null;
214
    private String session = null;
Lines 559-564 Link Here
559
    }
564
    }
560
565
561
    /**
566
    /**
567
     * get the character set for this email
568
     *
569
     * @return -  string that is the character set for this email
570
     *
571
     */
572
    public final String getCharset() {
573
	return charset;
574
    }
575
576
    /**
562
     * set true if error has occured
577
     * set true if error has occured
563
     *
578
     *
564
     * @param value  value that determines if an error has occured
579
     * @param value  value that determines if an error has occured
Lines 740-745 Link Here
740
	    type = "text/html";
755
	    type = "text/html";
741
	else
756
	else
742
	    type = "text/plain";
757
	    type = "text/plain";
758
    }
759
760
    /**
761
     * set the character set for this email
762
     *
763
     * @param value  string that is the character set for this email
764
     *
765
     */
766
    public final void setCharset(String value) {
767
        charset = value;
743
    }
768
    }
744
769
745
    /**
770
    /**
(-)src/org/apache/taglibs/mailer/MessageTag.java (+21 lines)
Lines 79-84 Link Here
79
 *            <required>false</required>
79
 *            <required>false</required>
80
 *            <rtexprvalue>false</rtexprvalue>
80
 *            <rtexprvalue>false</rtexprvalue>
81
 *      </attribute>
81
 *      </attribute>
82
 *      <attribute>
83
 *            <name>charset</name>
84
 *            <required>false</required>
85
 *            <rtexprvalue>false</rtexprvalue>
86
 *      </attribute>
82
 * </tag>
87
 * </tag>
83
 *
88
 *
84
 * @author Rich Catlett
89
 * @author Rich Catlett
Lines 95-100 Link Here
95
    private String type = "text";
100
    private String type = "text";
96
101
97
    /**
102
    /**
103
     * character set to be used (default is unspecified)
104
     */
105
    private String charset = null;
106
107
    /**
98
     *  implementation of the method from the tag interface that tells the JSP
108
     *  implementation of the method from the tag interface that tells the JSP
99
     *  page what to do after the body of this tag
109
     *  page what to do after the body of this tag
100
     *
110
     *
Lines 122-127 Link Here
122
        }
132
        }
123
	myparent.setMessage(message); // set message in the parent tag
133
	myparent.setMessage(message); // set message in the parent tag
124
	myparent.setType(type);  // set the mime type of the message
134
	myparent.setType(type);  // set the mime type of the message
135
	myparent.setCharset(charset);  // set the character set of the message
125
	return SKIP_BODY;
136
	return SKIP_BODY;
126
    }
137
    }
127
138
Lines 133-137 Link Here
133
     */
144
     */
134
    public final void setType(String value) {
145
    public final void setType(String value) {
135
	type = value;
146
	type = value;
147
    }
148
149
    /**
150
     * set the character set for this email
151
     *
152
     * @param value  string that is the character set for this email
153
     *
154
     */
155
    public final void setCharset(String value) {
156
	charset = value;
136
    }
157
    }
137
}
158
}
(-)src/org/apache/taglibs/mailer/SendTag.java (-2 / +18 lines)
Lines 353-359 Link Here
353
		MimeBodyPart mbp = new MimeBodyPart();
353
		MimeBodyPart mbp = new MimeBodyPart();
354
354
355
		// set the content in the bodypart 
355
		// set the content in the bodypart 
356
		mbp.setContent(myparent.getBody(), myparent.getType());
356
		mbp.setContent(myparent.getBody(), getContentType(myparent));
357
357
358
		// add the message as the first bodypart in the multipart object
358
		// add the message as the first bodypart in the multipart object
359
		multipart.addBodyPart(mbp);
359
		multipart.addBodyPart(mbp);
Lines 380-386 Link Here
380
	} else {
380
	} else {
381
	    try {
381
	    try {
382
		// set the message with a mimetype according to type set by user
382
		// set the message with a mimetype according to type set by user
383
		message.setContent(myparent.getBody(), myparent.getType());
383
		message.setContent(myparent.getBody(), getContentType(myparent));
384
	    } catch (MessagingException me) {
384
	    } catch (MessagingException me) {
385
		// this error is not very likely to occur
385
		// this error is not very likely to occur
386
		throw new JspException("The message could not be set in " +
386
		throw new JspException("The message could not be set in " +
Lines 438-443 Link Here
438
     */
438
     */
439
    public final ArrayList getError() {
439
    public final ArrayList getError() {
440
        return error;
440
        return error;
441
    }
442
443
    /**
444
     * get the content type, possibly including character set
445
     *
446
     * @return - complete encoded content type
447
     */
448
    public String getContentType(MailTag parent) {
449
        String type = parent.getType();
450
        String charset = parent.getCharset();
451
452
        if (charset == null) {
453
            return type;
454
        }
455
456
        return type + ";charset=" + charset;
441
    }
457
    }
442
}
458
}
443
459
(-)xml/mailer.xml (-1 / +12 lines)
Lines 406-412 Link Here
406
	    selected the body of the message is just plain text (it has no html 
406
	    selected the body of the message is just plain text (it has no html 
407
	    tags within it). If html is selected then the body of the message 
407
	    tags within it). If html is selected then the body of the message 
408
	    can contain HTML tags. The default value for this attribute is text.
408
	    can contain HTML tags. The default value for this attribute is text.
409
	</description>
409
        </description>
410
        <availability>1.0</availability>
411
      </attribute>
412
      <attribute>
413
        <name>charset</name>
414
        <required>no</required>
415
        <rtexprvalue>no</rtexprvalue>
416
        <description>
417
        This attribute specifies the character set of the message. If this
418
        attribute is not specified, no value will be included with the type
419
        of the message, leaving the default in place.
420
        </description>
410
        <availability>1.0</availability>
421
        <availability>1.0</availability>
411
      </attribute>
422
      </attribute>
412
423

Return to bug 23858