1 38 39 package org.jahia.deprecated.taglibs.button; 40 41 import java.io.IOException ; 42 import java.util.Locale ; 43 44 import javax.servlet.jsp.JspException ; 45 import javax.servlet.jsp.JspWriter ; 46 import javax.servlet.jsp.tagext.BodyTagSupport ; 47 48 import org.jahia.utils.LanguageCodeConverters; 49 import org.jahia.utils.TextHtml; 50 51 72 public class DisplayLanguageCodeTag extends BodyTagSupport { 73 74 78 public void setCode(String code) { 79 _code = code; 80 } 81 82 85 public void setHref(String href) { 86 _href = href; 87 } 88 89 93 public void setStyle(String style) { 94 _style = style; 95 } 96 97 public int doStartTag() { 98 99 try { 101 JspWriter out = pageContext.getOut(); 102 StringBuffer str = new StringBuffer (""); 103 if (debug) { 104 str.append("\n<!-- ======================================================================= -->\n"); 105 str.append("<!-- The following HTML code is generated by 'DisplayLanguageCodeTag' taglib -->\n"); 106 str.append("<!----------------------------------------------------------------------------->\n"); 107 } 108 if (!"".equals(_href)) { 109 str.append("<a "); 110 if (!"".equals(_style)) { 111 str.append("class=\""); 112 str.append(_style); 113 str.append("\" "); 114 } 115 str.append("href=\""); 116 str.append(_href); 117 str.append("\">"); 118 } 119 Locale localeLangToDisplay = LanguageCodeConverters.languageCodeToLocale(_code); 120 str.append(TextHtml.text2html(localeLangToDisplay.getDisplayLanguage(localeLangToDisplay))); 121 if (!"".equals(_href)) { 122 str.append("</a>"); 123 } 124 if (debug) { 125 str.append("\n<!-- ======================================================================= -->\n"); 126 } 127 out.print(str.toString()); 128 } catch (IOException ioe) { 129 logger.debug(ioe.toString()); 130 } 131 return SKIP_BODY; 132 } 133 134 public int doEndTag() throws JspException { 135 _code = ""; 138 _href = ""; 139 _style = ""; 140 return EVAL_PAGE; 141 } 142 143 private String _code = ""; 145 private String _href = ""; 146 private String _style = ""; 147 148 150 private boolean debug = false; 151 private static long imgID = 0; 152 153 private static org.apache.log4j.Logger logger = 154 org.apache.log4j.Logger.getLogger(DisplayLanguageCodeTag.class); 155 156 } | Popular Tags |