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.interfaces.IStaticDataList;
30 import org.dbforms.interfaces.StaticData;
31 import org.dbforms.util.MessageResources;
32 import org.dbforms.util.Util;
33
34 import javax.servlet.jsp.JspException;
35
36
37
38 /***
39 * DOCUMENT ME!
40 *
41 * @author $author$
42 * @version $Revision: 1.2 $
43 */
44 public class StaticDataItemTag extends AbstractDbBaseHandlerTag
45 implements javax.servlet.jsp.tagext.TryCatchFinally {
46 private static Log logCat = LogFactory.getLog(StaticDataItemTag.class.getName());
47 private String key;
48 private String value;
49
50 /***
51 * DOCUMENT ME!
52 *
53 * @param key DOCUMENT ME!
54 */
55 public void setKey(String key) {
56 this.key = key;
57 }
58
59
60 /***
61 * DOCUMENT ME!
62 *
63 * @return DOCUMENT ME!
64 */
65 public String getKey() {
66 return key;
67 }
68
69
70 /***
71 * DOCUMENT ME!
72 *
73 * @param string
74 */
75 public void setValue(String string) {
76 value = string;
77 }
78
79
80 /***
81 * DOCUMENT ME!
82 *
83 * @return DOCUMENT ME!
84 */
85 public String getValue() {
86 String message = null;
87
88 if ((value != null)
89 && (getParent() instanceof StaticDataTag
90 && (getParentForm() != null)
91 && getParentForm()
92 .hasCaptionResourceSet())) {
93 try {
94 message = MessageResources.getMessage(value, getLocale());
95
96 if (!Util.isNull(message)) {
97 value = message;
98 }
99 } catch (Exception e) {
100 logCat.debug("getValue(" + value + ") Exception : "
101 + e.getMessage());
102 }
103 }
104
105 return value;
106 }
107
108
109 /***
110 * DOCUMENT ME!
111 */
112 public void doFinally() {
113 key = null;
114 value = null;
115 super.doFinally();
116 }
117
118
119 /***
120 * DOCUMENT ME!
121 *
122 * @return DOCUMENT ME!
123 *
124 * @throws JspException DOCUMENT ME!
125 */
126 public int doStartTag() throws JspException {
127 if ((getParent() != null)
128 && getParent() instanceof IStaticDataList) {
129 ((IStaticDataList) getParent()).addElement(new StaticData(key,
130 getValue()));
131 } else {
132 throw new JspException("StaticDataItem element must be placed inside a AddStaticData element!");
133 }
134
135 return EVAL_BODY_INCLUDE;
136 }
137 }