1 64 65 package com.jcorporate.expresso.ext.struts.taglib.html; 66 67 73 74 import com.jcorporate.expresso.core.misc.StringUtil; 75 import org.apache.struts.taglib.html.BaseFieldTag; 76 import org.apache.struts.util.ResponseUtils; 77 78 import javax.servlet.jsp.JspException ; 79 80 121 122 127 public class ExLayerTag extends BaseFieldTag { 128 129 private String id = ""; 130 131 private String state = "SHOW"; 132 133 private String tag = "SPAN"; 134 135 136 private static String SPAN = "SPAN"; 137 private static String DIV = "DIV"; 138 private static String FONT = "FONT"; 139 140 protected static String SHOW = "block"; 141 protected static String HIDE = "none"; 142 143 146 public ExLayerTag() { 147 super(); 148 } 149 150 public int doStartTag() throws JspException { 151 152 StringBuffer results = new StringBuffer (); 153 results.append("<"); 154 results.append(tag); 155 results.append(" id=\""); 156 results.append(id); 157 results.append("\""); 158 results.append(prepareEventHandlers()); 159 String style = StringUtil.notNull(getStyle()); 160 setStyle("display:" + state + ";" + style); 161 results.append(prepareStyles()); 162 results.append(">"); 163 ResponseUtils.write(pageContext, results.toString()); 164 return EVAL_BODY_BUFFERED; 166 } 167 168 169 public int doEndTag() throws JspException { 170 StringBuffer results = new StringBuffer (); 171 results.append(getBodyContent().getString()); 172 results.append("</"); 173 results.append(tag); 174 results.append(">"); 175 ResponseUtils.write(pageContext, results.toString()); 176 return EVAL_PAGE; 177 } 178 179 184 public String getId() { 185 return id; 186 } 187 188 193 public void setId(String id) { 194 this.id = id; 195 } 196 197 202 public String getState() { 203 return state; 204 } 205 206 212 public void setState(String state) throws JspException { 213 if (state.equalsIgnoreCase("SHOW")) { 214 this.state = SHOW; 215 } else { 216 if (state.equalsIgnoreCase("HIDE")) { 217 this.state = HIDE; 218 } else { 219 throw new JspException ("state must be hide or show"); 220 } 221 } 222 } 223 224 229 public String getTag() { 230 return tag; 231 } 232 233 239 public void setTag(String tag) throws JspException { 240 if (tag.equalsIgnoreCase(SPAN)) { 241 this.tag = SPAN; 242 } else { 243 if (tag.equalsIgnoreCase(DIV)) { 244 this.tag = DIV; 245 } else { 246 if (tag.equalsIgnoreCase(FONT)) { 247 this.tag = FONT; 248 } else { 249 throw new JspException ("tag must be 'span' 'div' or 'font'"); 250 } 251 } 252 } 253 } 254 255 256 } 257 258 | Popular Tags |