001 package railo.runtime.tag; 002 003 import javax.servlet.jsp.tagext.Tag; 004 005 import railo.runtime.exp.ApplicationException; 006 import railo.runtime.exp.PageException; 007 import railo.runtime.ext.tag.BodyTagImpl; 008 009 /** 010 * Specifies one part of a multipart e-mail message. Can only be used in the cfmail tag. 011 * You can use more than one cfmailpart tag within a cfmail tag 012 * 013 * 014 * 015 **/ 016 public final class MailPart extends BodyTagImpl { 017 018 railo.runtime.net.mail.MailPart part=new railo.runtime.net.mail.MailPart(); 019 020 @Override 021 public void release() { 022 super.release(); 023 part=new railo.runtime.net.mail.MailPart(); 024 } 025 026 /** 027 * @param type The type to set. 028 * @throws ApplicationException 029 */ 030 public void setType(String type) throws ApplicationException { 031 part.setType(type); 032 } 033 034 035 /** 036 * @param charset The charset to set. 037 */ 038 public void setCharset(String charset) { 039 part.setCharset(charset); 040 } 041 042 /** 043 * @param wraptext The wraptext to set. 044 */ 045 public void setWraptext(double wraptext) { 046 part.setWraptext((int)wraptext); 047 } 048 049 @Override 050 public int doStartTag() { 051 052 return EVAL_BODY_BUFFERED; 053 } 054 055 @Override 056 public void doInitBody() { 057 058 } 059 060 @Override 061 public int doAfterBody() { 062 part.setBody(bodyContent.getString()); 063 return SKIP_BODY; 064 } 065 066 @Override 067 public int doEndTag() throws PageException { 068 069 getMail().addPart(part); 070 /*String type = part.getType(); 071 if(StringUtil.isEmpty(part.getCharset())) part.setCharset(mail.getCharset()); 072 if(type!=null && (type.equals("text/plain") || type.equals("plain") || type.equals("text"))){ 073 part.isPlain(true); 074 mail.setBodyPart(part); 075 } 076 else if(type!=null && (type.equals("text/html") || type.equals("html") || type.equals("htm"))){ 077 part.isHTML(true); 078 mail.setBodyPart(part); 079 } 080 else { 081 082 getMail().setParam(type, null, "susi", part.getBody(), "inline", null); 083 }*/ 084 // throw new ApplicationException("attribute type of tag mailpart has an invalid values","valid values are [plain,text,html] but value is now ["+type+"]"); 085 086 087 088 return EVAL_PAGE; 089 } 090 091 092 093 private Mail getMail() throws ApplicationException { 094 Tag parent=getParent(); 095 while(parent!=null && !(parent instanceof Mail)) { 096 parent=parent.getParent(); 097 } 098 if(parent instanceof Mail)return (Mail) parent; 099 throw new ApplicationException("Wrong Context, tag MailPart must be inside a Mail tag"); 100 } 101 }