001package com.hfg.html;
002
003
004import com.hfg.xml.XMLNode;
005
006//------------------------------------------------------------------------------
007/**
008 * Represents a textarea (<textarea>) tag.
009 *
010 * @author J. Alex Taylor, hairyfatguy.com
011 */
012//------------------------------------------------------------------------------
013// com.hfg XML/HTML Coding Library
014//
015// This library is free software; you can redistribute it and/or
016// modify it under the terms of the GNU Lesser General Public
017// License as published by the Free Software Foundation; either
018// version 2.1 of the License, or (at your option) any later version.
019//
020// This library is distributed in the hope that it will be useful,
021// but WITHOUT ANY WARRANTY; without even the implied warranty of
022// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
023// Lesser General Public License for more details.
024//
025// You should have received a copy of the GNU Lesser General Public
026// License along with this library; if not, write to the Free Software
027// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
028//
029// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com
030// jataylor@hairyfatguy.com
031//------------------------------------------------------------------------------
032
033public class Textarea extends HTMLTagWithFormEvents
034{
035
036    //##########################################################################
037    // PRIVATE FIELDS
038    //##########################################################################
039
040    //##########################################################################
041    // CONSTRUCTORS
042    //##########################################################################
043
044    //--------------------------------------------------------------------------
045    public Textarea()
046    {
047        super(HTML.TEXTAREA);
048
049        // This defeats isEmptyTag() so that the textarea will always be printed
050        // as a tag pair. Some browsers (at least Mozilla and Safari) have trouble
051        // with a textarea written as an empty tag.
052        setContent("");
053    }
054
055    //--------------------------------------------------------------------------
056    public Textarea(String inName, String inValue)
057    {
058        this();
059        addContent(inValue);
060        setName(inName);
061    }
062
063    //--------------------------------------------------------------------------
064    public Textarea(String inName, String inValue, int inRows, int inCols)
065    {
066        this(inName, inValue);
067        setRows(inRows);
068        setCols(inCols);
069    }
070
071    //--------------------------------------------------------------------------
072    public Textarea(XMLNode inXMLNode)
073    {
074        this();
075        initFromXMLNode(inXMLNode);
076    }
077
078    //##########################################################################
079    // PUBLIC METHODS
080    //##########################################################################
081
082    //--------------------------------------------------------------------------
083    public Textarea setName(String inValue)
084    {
085        setAttribute(HTML.NAME, inValue);
086
087        return this;
088    }
089
090    //--------------------------------------------------------------------------
091    public String getName()
092    {
093        return getAttributeValue(HTML.NAME);
094    }
095
096    //--------------------------------------------------------------------------
097    public Textarea setCols(int inValue)
098    {
099        setAttribute(HTML.COLS, inValue);
100
101        return this;
102    }
103
104    //--------------------------------------------------------------------------
105    public String getCols()
106    {
107        return getAttributeValue(HTML.COLS);
108    }
109
110    //--------------------------------------------------------------------------
111    public Textarea setRows(int inValue)
112    {
113        setAttribute(HTML.ROWS, inValue);
114
115        return this;
116    }
117
118    //--------------------------------------------------------------------------
119    public String getRows()
120    {
121        return getAttributeValue(HTML.ROWS);
122    }
123
124    //--------------------------------------------------------------------------
125    public Textarea setWrapOff()
126    {
127        setAttribute(HTML.WRAP, HTML.OFF);
128
129        return this;
130    }
131
132    //--------------------------------------------------------------------------
133    public Textarea setWrap(String inValue)
134    {
135        setAttribute(HTML.WRAP, inValue);
136
137        return this;
138    }
139
140    //--------------------------------------------------------------------------
141    public String getWrap()
142    {
143        return getAttributeValue(HTML.WRAP);
144    }
145
146    //--------------------------------------------------------------------------
147    public Textarea setDisabled(boolean disabled)
148    {
149        if (disabled) {
150            setAttribute(HTML.DISABLED, HTML.DISABLED);
151        }
152        else {
153            removeAttribute(HTML.DISABLED);
154        }
155
156        return this;
157    }
158
159    //--------------------------------------------------------------------------
160    public boolean isDisabled()
161    {
162        return hasAttribute(HTML.DISABLED);
163    }
164
165    //--------------------------------------------------------------------------
166    public Textarea setOnSelect(String inValue)
167    {
168        setAttribute(HTML.ONSELECT, inValue);
169        return this;
170    }
171
172    //--------------------------------------------------------------------------
173    public String getOnSelect()
174    {
175        return getAttributeValue(HTML.ONSELECT);
176    }
177
178    // Overrides for HTMLTag setters to allow method chaining.
179
180    //--------------------------------------------------------------------------
181    @Override
182    public Textarea addClass(String inValue)
183    {
184        return (Textarea) super.addClass(inValue);
185    }
186
187    //--------------------------------------------------------------------------
188    @Override
189    public Textarea setClass(String inValue)
190    {
191        return (Textarea) super.setClass(inValue);
192    }
193
194    //--------------------------------------------------------------------------
195    @Override
196    public Textarea setId(String inValue)
197    {
198        return (Textarea) super.setId(inValue);
199    }
200
201    //--------------------------------------------------------------------------
202    @Override
203    public Textarea setStyle(CharSequence inValue)
204    {
205        return (Textarea) super.setStyle(inValue);
206    }
207
208    //--------------------------------------------------------------------------
209    @Override
210    public Textarea addStyle(String inValue)
211    {
212        return (Textarea) super.addStyle(inValue);
213    }
214
215    // Overrides for HTMLTagWithCoreEvents setters to allow method chaining.
216
217    //--------------------------------------------------------------------------
218    @Override
219    public Textarea setOnClick(String inValue)
220    {
221        return (Textarea) super.setOnClick(inValue);
222    }
223
224    //--------------------------------------------------------------------------
225    @Override
226    public Textarea setOnDblClick(String inValue)
227    {
228        return (Textarea) super.setOnDblClick(inValue);
229    }
230
231    //--------------------------------------------------------------------------
232    @Override
233    public Textarea setOnMouseDown(String inValue)
234    {
235        return (Textarea) super.setOnMouseDown(inValue);
236    }
237
238    //--------------------------------------------------------------------------
239    @Override
240    public Textarea setOnMouseMove(String inValue)
241    {
242        return (Textarea) super.setOnMouseMove(inValue);
243    }
244
245    //--------------------------------------------------------------------------
246    @Override
247    public Textarea appendToOnMouseOut(String inValue)
248    {
249        return (Textarea) super.appendToOnMouseOut(inValue);
250    }
251
252    //--------------------------------------------------------------------------
253    @Override
254    public Textarea setOnMouseOut(String inValue)
255    {
256        return (Textarea) super.setOnMouseOut(inValue);
257    }
258
259    //--------------------------------------------------------------------------
260    @Override
261    public Textarea appendToOnMouseOver(String inValue)
262    {
263        return (Textarea) super.appendToOnMouseOver(inValue);
264    }
265
266    //--------------------------------------------------------------------------
267    @Override
268    public Textarea setOnMouseOver(String inValue)
269    {
270        return (Textarea) super.setOnMouseOver(inValue);
271    }
272
273    //--------------------------------------------------------------------------
274    @Override
275    public Textarea setOnMouseUp(String inValue)
276    {
277        return (Textarea) super.setOnMouseUp(inValue);
278    }
279
280    //--------------------------------------------------------------------------
281    @Override
282    public Textarea setOnKeyDown(String inValue)
283    {
284        return (Textarea) super.setOnKeyDown(inValue);
285    }
286
287    //--------------------------------------------------------------------------
288    @Override
289    public Textarea setOnKeyPress(String inValue)
290    {
291        return (Textarea) super.setOnKeyPress(inValue);
292    }
293
294    //--------------------------------------------------------------------------
295    @Override
296    public Textarea setOnKeyUp(String inValue)
297    {
298        return (Textarea) super.setOnKeyUp(inValue);
299    }
300
301    // Overrides for HTMLTagWithFormEvents setters to allow method chaining.
302
303    //--------------------------------------------------------------------------
304    @Override
305    public Textarea setOnBlur(String inValue)
306    {
307        return (Textarea) super.setOnBlur(inValue);
308    }
309
310    //--------------------------------------------------------------------------
311    @Override
312    public Textarea setOnChange(String inValue)
313    {
314        return (Textarea) super.setOnChange(inValue);
315    }
316
317    //--------------------------------------------------------------------------
318    @Override
319    public Textarea setOnFocus(String inValue)
320    {
321        return (Textarea) super.setOnFocus(inValue);
322    }
323}