KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > dbforms > taglib > StaticDataItem


1 /*
2  * $Header: /cvsroot/jdbforms/dbforms/src/org/dbforms/taglib/StaticDataItem.java,v 1.17 2004/08/18 12:26:08 hkollmann Exp $
3  * $Revision: 1.17 $
4  * $Date: 2004/08/18 12:26:08 $
5  *
6  * DbForms - a Rapid Application Development Framework
7  * Copyright (C) 2001 Joachim Peer <joepeer@excite.com>
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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.KeyValuePair;
30 import org.dbforms.util.MessageResources;
31 import org.dbforms.util.Util;
32
33 import javax.servlet.jsp.JspException JavaDoc;
34
35
36
37 /**
38  * DOCUMENT ME!
39  *
40  * @author $author$
41  * @version $Revision: 1.17 $
42  */

43 public class StaticDataItem extends DbBaseHandlerTag
44    implements javax.servlet.jsp.tagext.TryCatchFinally JavaDoc {
45    private static Log logCat = LogFactory.getLog(StaticDataItem.class.getName()); // logging category for this class
46
private String JavaDoc key;
47    private String JavaDoc value;
48
49    /**
50     * DOCUMENT ME!
51     *
52     * @param key DOCUMENT ME!
53     */

54    public void setKey(String JavaDoc key) {
55       this.key = key;
56    }
57
58
59    /**
60     * DOCUMENT ME!
61     *
62     * @return DOCUMENT ME!
63     */

64    public String JavaDoc getKey() {
65       return key;
66    }
67
68
69    /**
70     * DOCUMENT ME!
71     *
72     * @param string
73     */

74    public void setValue(String JavaDoc string) {
75       value = string;
76    }
77
78
79    /**
80     * DOCUMENT ME!
81     *
82     * @return DOCUMENT ME!
83     */

84    public String JavaDoc getValue() {
85       String JavaDoc message = null;
86
87       if ((value != null)
88                 && (getParent() instanceof StaticData
89                 && getParent()
90                             .getParent() instanceof DbBaseHandlerTag
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 JavaDoc e) {
100             logCat.debug("getValue(" + value + ") Exception : "
101                          + e.getMessage());
102          }
103       }
104
105       return value;
106    }
107
108
109    /**
110     * @see javax.servlet.jsp.tagext.TryCatchFinally#doCatch(java.lang.Throwable)
111     */

112    public void doCatch(Throwable JavaDoc t) throws Throwable JavaDoc {
113       throw t;
114    }
115
116
117    /**
118     * DOCUMENT ME!
119     */

120    public void doFinally() {
121       key = null;
122       value = null;
123       super.doFinally();
124    }
125
126
127    /**
128     * DOCUMENT ME!
129     *
130     * @return DOCUMENT ME!
131     *
132     * @throws JspException DOCUMENT ME!
133     */

134    public int doStartTag() throws JspException JavaDoc {
135       if ((getParent() != null)
136                 && getParent() instanceof StaticDataAddInterface) {
137          ((StaticDataAddInterface) getParent()).addElement(new KeyValuePair(key,
138                                                                             getValue()));
139       } else {
140          throw new JspException JavaDoc("StaticDataItem element must be placed inside a AddStaticData element!");
141       }
142
143       return EVAL_BODY_INCLUDE;
144    }
145 }
146
Popular Tags