1 22 23 package org.meshcms.taglib; 24 25 import java.io.*; 26 import java.text.*; 27 import java.util.*; 28 import javax.servlet.*; 29 import javax.servlet.jsp.*; 30 import org.meshcms.core.*; 31 import org.meshcms.util.*; 32 33 38 public final class MailForm extends AbstractTag { 39 public void writeTag() throws IOException, JspException { 40 String email = getPage().getProperty(PageAssembler.EMAIL_PARAM); 41 42 if (Utils.checkAddress(email)) { 43 try { 44 Path mailModulePath = webSite.getAdminModulesPath().add("mail"); 45 String location = "meshcmsmailformtag"; 46 ModuleDescriptor md = new ModuleDescriptor(); 47 md.setLocation(location); 48 md.setArgument(email); 49 md.setModulePath(mailModulePath); 50 md.setPagePath(pagePath); 51 String moduleCode = "meshcmsmodule_" + location; 52 request.setAttribute(moduleCode, md); 53 pageContext.include("/" + webSite.getServedPath(mailModulePath) + "/" + 54 SiteMap.MODULE_INCLUDE_FILE + "?modulecode=" + moduleCode); 55 } catch (ServletException ex) { 56 throw new JspException(ex); 57 } 58 } else { 59 getOut().write(" "); 60 } 61 } 62 63 public void writeEditTag() throws IOException, JspException { 64 final String uniqueHash = Integer.toString(new Object ().hashCode()); 65 final String tagIdPrefix = "meshcmsmodule_mail_"+ uniqueHash +"_"; 66 final String idCont = tagIdPrefix +"cont"; 67 final String idElem = tagIdPrefix +"elem"; 68 final String idIcon = tagIdPrefix +"icon"; 69 final boolean isEditorModulesCollapsed = webSite.getConfiguration().isEditorModulesCollapsed(); 70 71 Locale locale = WebUtils.getPageLocale(pageContext); 72 ResourceBundle bundle = ResourceBundle.getBundle("org/meshcms/webui/Locales", locale); 73 74 String email = getPage().getProperty(PageAssembler.EMAIL_PARAM); 75 76 Writer w = getOut(); 77 78 if (isEditorModulesCollapsed) { 79 MessageFormat formatter = new MessageFormat("", locale); 80 w.write("<div id=\""+ idCont +"\" class='meshcmsfieldlabel' " + 81 " style=\"cursor:pointer;\" onclick=\"javascript:editor_moduleShow('"+ idCont +"','"+ idElem +"','"+ idIcon +"');\">" + 82 "<img alt=\"\" SRC=\"" + afp + "/images/tree_plus.gif\" id=\""+ idIcon +"\" />\n"); 83 Object [] args = { bundle.getString("editorMailTitle"), email != null ? bundle.getString("editorMailTitle") : bundle.getString("editorNoTemplate"), 84 Utils.noNull(email), "" }; 85 formatter.applyPattern(bundle.getString("editorModuleLocExt")); 86 w.write("<label for=\""+ idElem +"\">"+ formatter.format(args) +"</label>"); 87 w.write("</div>"); 88 } 89 90 w.write("<fieldset "+ (isEditorModulesCollapsed ? "style=\"display:none;\"" : "") + 91 "class='meshcmseditor' id=\""+ idElem +"\">\n"); 92 w.write("<legend>" + bundle.getString("editorMailTitle") + "</legend>\n"); 93 w.write("<div class='meshcmsfieldlabel'>" + bundle.getString("editorMail") + "</div>\n"); 94 w.write("<div class='meshcmsfield'><img alt=\"\" SRC='" + afp + 95 "/images/clear_field.gif' onclick=\"javascript:editor_clr('" + 96 PageAssembler.EMAIL_PARAM + "');\" style='vertical-align:middle;' /><input type='text' id='" + 97 PageAssembler.EMAIL_PARAM + "' name='" + 98 PageAssembler.EMAIL_PARAM + "' value=\"" + 99 Utils.noNull(email) + "\" style='width: 12em;' /></div>\n"); 100 w.write("</fieldset>"); 101 } 102 } 103 | Popular Tags |