KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Header: /cvsroot/jdbforms/dbforms/src/org/dbforms/taglib/DbTextAreaTag.java,v 1.24 2004/08/18 12:26:08 hkollmann Exp $
3  * $Revision: 1.24 $
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 javax.servlet.jsp.JspException JavaDoc;
27
28
29
30 /**
31  * <p>
32  * This tag renders a HTML TextArea - Element
33  * </p>
34  * this tag renders a dabase-datadriven textArea, which is an active element -
35  * the user can change data
36  *
37  * @author Joachim Peer
38  */

39 public class DbTextAreaTag extends DbBaseInputTag
40    implements javax.servlet.jsp.tagext.TryCatchFinally JavaDoc {
41    /** DOCUMENT ME! */
42    protected String JavaDoc renderBody;
43
44    /** DOCUMENT ME! */
45    protected String JavaDoc wrap;
46
47    /**
48     * Sets the renderBody
49     *
50     * @param renderBody The renderBody to set
51     */

52    public void setRenderBody(String JavaDoc renderBody) {
53       this.renderBody = renderBody;
54    }
55
56
57    /**
58     * Gets the renderBody
59     *
60     * @return Returns a String
61     */

62    public String JavaDoc getRenderBody() {
63       return renderBody;
64    }
65
66
67    /**
68     * DOCUMENT ME!
69     *
70     * @param wrap DOCUMENT ME!
71     */

72    public void setWrap(String JavaDoc wrap) {
73       this.wrap = wrap;
74    }
75
76
77    /**
78     * DOCUMENT ME!
79     *
80     * @return DOCUMENT ME!
81     */

82    public String JavaDoc getWrap() {
83       return wrap;
84    }
85
86
87    /**
88     * @see javax.servlet.jsp.tagext.TryCatchFinally#doCatch(java.lang.Throwable)
89     */

90    public void doCatch(Throwable JavaDoc t) throws Throwable JavaDoc {
91       throw t;
92    }
93
94
95    /**
96     * DOCUMENT ME!
97     *
98     * @return DOCUMENT ME!
99     *
100     * @throws javax.servlet.jsp.JspException DOCUMENT ME!
101     * @throws JspException DOCUMENT ME!
102     */

103    public int doEndTag() throws javax.servlet.jsp.JspException JavaDoc {
104       try {
105          if ("true".equals(renderBody) && (bodyContent != null)) {
106             bodyContent.writeOut(bodyContent.getEnclosingWriter());
107             bodyContent.clearBody(); // workaround for duplicate rows in JRun 3.1
108
}
109
110          pageContext.getOut()
111                     .write("</textArea>");
112
113          // Writes out the old field value
114
writeOutSpecialValues();
115
116          // For generation Javascript Validation. Need all original and modified fields name
117
getParentForm()
118             .addChildName(getName(), getFormFieldName());
119       } catch (java.io.IOException JavaDoc ioe) {
120          throw new JspException JavaDoc("IO Error: " + ioe.getMessage());
121       }
122
123       return EVAL_PAGE;
124    }
125
126
127    /**
128     * DOCUMENT ME!
129     */

130    public void doFinally() {
131       wrap = null;
132       renderBody = null;
133       super.doFinally();
134    }
135
136
137    /**
138     * DOCUMENT ME!
139     *
140     * @return DOCUMENT ME!
141     *
142     * @throws javax.servlet.jsp.JspException DOCUMENT ME!
143     * @throws JspException DOCUMENT ME!
144     */

145    public int doStartTag() throws javax.servlet.jsp.JspException JavaDoc {
146       super.doStartTag();
147
148       StringBuffer JavaDoc tagBuf = new StringBuffer JavaDoc("<textarea ");
149
150       tagBuf.append(prepareName());
151
152       if (wrap != null) {
153          tagBuf.append(" wrap=\"");
154          tagBuf.append(wrap);
155          tagBuf.append("\"");
156       }
157
158       if (getCols() != null) {
159          tagBuf.append(" cols=\"");
160          tagBuf.append(getCols());
161          tagBuf.append("\"");
162       }
163
164       if (getRows() != null) {
165          tagBuf.append(" rows=\"");
166          tagBuf.append(getRows());
167          tagBuf.append("\"");
168       }
169
170       tagBuf.append(prepareKeys());
171       tagBuf.append(prepareStyles());
172       tagBuf.append(prepareEventHandlers());
173       tagBuf.append(">");
174
175       /* If the overrideValue attribute has been set, use its value instead of the one
176       retrieved from the database. This mechanism can be used to set an initial default
177       value for a given field. */

178       if (!"true".equals(renderBody)) {
179          tagBuf.append(escapeHTML(getFormFieldValue()));
180       }
181
182       try {
183          pageContext.getOut()
184                     .write(tagBuf.toString());
185       } catch (java.io.IOException JavaDoc e) {
186          throw new JspException JavaDoc("IO Error: " + e.getMessage());
187       }
188
189       if (!"true".equals(renderBody)) {
190          return EVAL_BODY_BUFFERED;
191       } else {
192          return SKIP_BODY;
193       }
194    }
195 }
196
Popular Tags