1 22 23 package org.meshcms.taglib; 24 25 import java.io.*; 26 import java.text.*; 27 import java.util.*; 28 import org.meshcms.core.*; 29 import org.meshcms.util.*; 30 import com.opensymphony.module.sitemesh.*; 31 32 37 public class PageTitle extends AbstractTag { 38 private String defaultTitle = " "; 39 40 public void setDefault(String defaultTitle) { 41 this.defaultTitle = Utils.noNull(defaultTitle); 42 } 43 44 public String getDefault() { 45 return defaultTitle; 46 } 47 48 public String getTitle() { 49 String title = null; 50 Page page = getPage(); 51 52 if (page != null) { 53 title = page.getTitle(); 54 } 55 56 if (Utils.isNullOrEmpty(title)) { 57 title = defaultTitle; 58 } 59 60 return title; 61 } 62 63 public void writeTag() throws IOException { 64 getOut().write(getTitle()); 65 } 66 67 public void writeEditTag() throws IOException { 68 Locale locale = WebUtils.getPageLocale(pageContext); 69 ResourceBundle bundle = ResourceBundle.getBundle("org/meshcms/webui/Locales", locale); 70 MessageFormat formatter = new MessageFormat("", locale); 71 72 Object [] args = { getTitle() }; 73 formatter.applyPattern(bundle.getString("editorTitle")); 74 getOut().write(formatter.format(args)); 75 } 76 } 77 | Popular Tags |