1 38 39 package org.jahia.deprecated.taglibs.button; 40 41 import java.io.IOException ; 42 43 import javax.servlet.http.HttpServletRequest ; 44 import javax.servlet.jsp.JspException ; 45 import javax.servlet.jsp.JspWriter ; 46 import javax.servlet.jsp.tagext.BodyTagSupport ; 47 48 import org.jahia.data.JahiaData; 49 import org.jahia.resourcebundle.JahiaResourceBundle; 50 51 71 public class DisplayIconTag extends BodyTagSupport { 72 73 77 public void setSrc(String src) { 78 _src = src; 79 } 80 81 84 public void setResource(String resource) { 85 _resource = resource; 86 } 87 88 91 public void setHeight(Integer height) { 92 _height = height; 93 } 94 95 98 public void setWidth(Integer width) { 99 _width = width; 100 } 101 102 105 public void setAlt(String alt) { 106 _alt = alt; 107 } 108 109 public void setAltKey(String altKey) { 110 this.altKey = altKey; 111 } 112 113 public void setAltBundle(String altBundle) { 114 this.altBundle = altBundle; 115 } 116 117 120 public void setAlign(String align) { 121 _align = align; 122 } 123 124 public int doStartTag() { 125 126 HttpServletRequest request = (HttpServletRequest )pageContext.getRequest(); 129 JahiaData jData = (JahiaData)request.getAttribute("org.jahia.data.JahiaData"); 130 131 if (altKey != null) { 133 _alt = JahiaResourceBundle.getResource(altBundle, altKey, jData.params().getLocale(), jData.params()); 134 } 135 136 try { 138 JspWriter out = pageContext.getOut(); 139 StringBuffer str = new StringBuffer (""); 140 String imagePath = JahiaResourceBundle.getUrlPathCommonResource( 142 _src, jData.params()); 143 if (("".equals(_resource)) && (imagePath == null)) { 144 str.append("<!-- couldn't find resource with key " + _src + " -->"); 145 } else { 146 str.append("<img alt=\""); 148 str.append(_alt); 149 str.append("\" border=\"0\" SRC=\""); 150 if ("".equals(_resource)) { 151 str.append(imagePath); 152 } else { 153 str.append(_resource); 154 } 155 str.append("\""); 156 if (_height != null) { 157 str.append(" height=\""); 158 str.append(_height.intValue()); 159 str.append("\""); 160 } 161 if (_width != null) { 162 str.append(" width=\""); 163 str.append(_width.intValue()); 164 str.append("\""); 165 } 166 if (_align != null) { 167 str.append(" align=\""); 168 str.append(_align); 169 str.append("\""); 170 } 171 str.append(">"); 172 } 173 out.print(str.toString()); 174 } catch (IOException ioe) { 175 logger.debug(ioe.toString()); 176 } 177 return SKIP_BODY; 178 } 179 180 public int doEndTag() throws JspException { 181 _src = ""; 184 _resource = ""; 185 _alt = ""; 186 altKey = null; 187 altBundle = null; 188 _height = null; 189 _width = null; 190 _align = ""; 191 return EVAL_PAGE; 192 } 193 194 195 private String _src = ""; 197 private String _resource = ""; 198 private String _alt = ""; 199 private String altKey = null; 200 private String altBundle = null; 201 private Integer _height = null; 202 private Integer _width = null; 203 private String _align = ""; 204 205 private static long imgID = 0; 206 207 private static org.apache.log4j.Logger logger = 208 org.apache.log4j.Logger.getLogger(DisplayIconTag.class); 209 210 } 211 | Popular Tags |