1 23 24 package org.dbforms.taglib; 25 26 import org.apache.commons.logging.Log; 27 import org.apache.commons.logging.LogFactory; 28 29 import org.dbforms.util.Util; 30 31 import javax.servlet.jsp.JspException ; 32 33 34 35 43 public class DbLabelTag extends DbBaseHandlerTag 44 implements javax.servlet.jsp.tagext.TryCatchFinally { 45 static Log logCat = LogFactory.getLog(DbLabelTag.class.getName()); 47 48 51 public void doCatch(Throwable t) throws Throwable { 52 throw t; 53 } 54 55 56 63 public int doEndTag() throws javax.servlet.jsp.JspException { 64 try { 65 String fieldValue = getFormattedFieldValue(); 66 67 String size = null; 70 71 if (((size = this.getMaxlength()) != null) 72 && (size.trim() 73 .length() > 0)) { 74 int count = Integer.parseInt(size); 76 77 if (count < fieldValue.length()) { 79 fieldValue = fieldValue.substring(0, count); 80 fieldValue += "..."; 81 } 82 } 83 84 String s = prepareStyles(); 87 fieldValue = escapeHTML(fieldValue); 88 89 if (Util.isNull(s)) { 90 pageContext.getOut() 91 .write(fieldValue); 92 } else { 93 pageContext.getOut() 94 .write("<span " + s +">" + fieldValue + "</span>"); 95 } 96 } catch (java.io.IOException ioe) { 97 logCat.error("::doEndTag - IO Error", ioe); 99 throw new JspException ("IO Error: " + ioe.getMessage()); 100 } catch (Exception e) { 101 logCat.error("::doEndTag - general exception", e); 103 throw new JspException ("Error: " + e.getMessage()); 104 } 105 106 return EVAL_PAGE; 107 } 108 109 110 113 public void doFinally() { 114 super.doFinally(); 115 } 116 } 117 | Popular Tags |