1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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 /***
36 * this tag renders a dabase-datadriven LABEL, which is apassive element (it
37 * can't be changed by the user) - it is predestinated for use with read-only
38 * data (i.e. primary keys you don't want the user to change, etc)
39 *
40 * @author Joachim Peer
41 *
42 */
43 public class DbLabelTag extends AbstractDbBaseHandlerTag
44 implements javax.servlet.jsp.tagext.TryCatchFinally {
45
46 static Log logCat = LogFactory.getLog(DbLabelTag.class.getName());
47
48 /***
49 * Description of the Method
50 *
51 * @return Description of the Return Value
52 *
53 * @exception javax.servlet.jsp.JspException Description of the Exception
54 */
55 public int doEndTag() throws javax.servlet.jsp.JspException {
56 try {
57 String fieldValue = getFormattedFieldValue();
58
59
60
61 String size = null;
62
63 if (((size = this.getMaxlength()) != null)
64 && (size.trim()
65 .length() > 0)) {
66
67 int count = Integer.parseInt(size);
68
69
70 if (count < fieldValue.length()) {
71 fieldValue = fieldValue.substring(0, count);
72 fieldValue += "...";
73 }
74 }
75
76
77
78 String s = prepareStyles();
79 fieldValue = escapeHTML(fieldValue);
80
81 if (Util.isNull(s)) {
82 pageContext.getOut()
83 .write(fieldValue);
84 } else {
85 pageContext.getOut()
86 .write("<span " + s +">" + fieldValue + "</span>");
87 }
88 } catch (java.io.IOException ioe) {
89
90 logCat.error("::doEndTag - IO Error", ioe);
91 throw new JspException("IO Error: " + ioe.getMessage());
92 } catch (Exception e) {
93
94 logCat.error("::doEndTag - general exception", e);
95 throw new JspException("Error: " + e.getMessage());
96 }
97
98 return EVAL_PAGE;
99 }
100
101
102 /***
103 * DOCUMENT ME!
104 */
105 public void doFinally() {
106 super.doFinally();
107 }
108 }