001package com.hfg.html;
002
003
004//------------------------------------------------------------------------------
005/**
006 * Represents a text input form element (<input type='text'>) tag.
007 *
008 * @author J. Alex Taylor, hairyfatguy.com
009 */
010//------------------------------------------------------------------------------
011// com.hfg XML/HTML Coding Library
012//
013// This library is free software; you can redistribute it and/or
014// modify it under the terms of the GNU Lesser General Public
015// License as published by the Free Software Foundation; either
016// version 2.1 of the License, or (at your option) any later version.
017//
018// This library is distributed in the hope that it will be useful,
019// but WITHOUT ANY WARRANTY; without even the implied warranty of
020// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
021// Lesser General Public License for more details.
022//
023// You should have received a copy of the GNU Lesser General Public
024// License along with this library; if not, write to the Free Software
025// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
026//
027// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com
028// jataylor@hairyfatguy.com
029//------------------------------------------------------------------------------
030
031public class InputText extends HTMLTagWithFormEvents
032{
033
034    //##########################################################################
035    // CONSTRUCTORS
036    //##########################################################################
037
038    //--------------------------------------------------------------------------
039    public InputText()
040    {
041        super(HTML.INPUT);
042        setAttribute(HTML.TYPE, "text");
043    }
044
045    //--------------------------------------------------------------------------
046    public InputText(String inName, String inValue)
047    {
048        this();
049        setName(inName);
050        setValue(inValue);
051    }
052
053    //##########################################################################
054    // PUBLIC METHODS
055    //##########################################################################
056
057    //--------------------------------------------------------------------------
058    public InputText setName(String inValue)
059    {
060        setAttribute(HTML.NAME, inValue);
061
062        return this;
063    }
064
065    //--------------------------------------------------------------------------
066    public String getName()
067    {
068        return getAttributeValue(HTML.NAME);
069    }
070
071    //--------------------------------------------------------------------------
072    public InputText setValue(String inValue)
073    {
074        setAttribute(HTML.VALUE, inValue);
075
076        return this;
077    }
078
079    //--------------------------------------------------------------------------
080    public String getValue()
081    {
082        return getAttributeValue(HTML.VALUE);
083    }
084
085    //--------------------------------------------------------------------------
086    public InputText setSize(int inValue)
087    {
088        setAttribute(HTML.SIZE, Integer.toString(inValue));
089
090        return this;
091    }
092
093    //--------------------------------------------------------------------------
094    public InputText setMaxLength(int inValue)
095    {
096        setAttribute(HTML.MAX_LENGTH, Integer.toString(inValue));
097
098        return this;
099    }
100
101
102    //--------------------------------------------------------------------------
103    public InputText setDisabled(boolean disabled)
104    {
105        if (disabled) {
106            setAttribute(HTML.DISABLED, HTML.DISABLED);
107        }
108        else {
109            removeAttribute(HTML.DISABLED);
110        }
111
112        return this;
113    }
114
115    //--------------------------------------------------------------------------
116    public boolean isDisabled()
117    {
118        return hasAttribute(HTML.DISABLED);
119    }
120
121
122    //--------------------------------------------------------------------------
123    public InputText setTitle(String inValue)
124    {
125        setAttribute(HTML.TITLE, inValue);
126        return this;
127    }
128
129    //--------------------------------------------------------------------------
130    public String getTitle()
131    {
132        return getAttributeValue(HTML.TITLE);
133    }
134
135
136    //--------------------------------------------------------------------------
137    public InputText setOnSelect(String inValue)
138    {
139        setAttribute(HTML.ONSELECT, inValue);
140        return this;
141    }
142
143    //--------------------------------------------------------------------------
144    public String getOnSelect()
145    {
146        return getAttributeValue(HTML.ONSELECT);
147    }
148
149
150    // Overrides for HTMLTag setters to allow method chaining.
151
152    //--------------------------------------------------------------------------
153    @Override
154    public InputText setId(String inValue)
155    {
156        return (InputText) super.setId(inValue);
157    }
158
159    //--------------------------------------------------------------------------
160    @Override
161    public InputText setStyle(CharSequence inValue)
162    {
163        return (InputText) super.setStyle(inValue);
164    }
165
166    //--------------------------------------------------------------------------
167    @Override
168    public InputText addStyle(String inValue)
169    {
170        return (InputText) super.addStyle(inValue);
171    }
172
173    // Overrides for HTMLTagWithCoreEvents setters to allow method chaining.
174
175    //--------------------------------------------------------------------------
176    @Override
177    public InputText setOnClick(String inValue)
178    {
179        return (InputText) super.setOnClick(inValue);
180    }
181
182    //--------------------------------------------------------------------------
183    @Override
184    public InputText setOnDblClick(String inValue)
185    {
186        return (InputText) super.setOnDblClick(inValue);
187    }
188
189    //--------------------------------------------------------------------------
190    @Override
191    public InputText setOnMouseDown(String inValue)
192    {
193        return (InputText) super.setOnMouseDown(inValue);
194    }
195
196    //--------------------------------------------------------------------------
197    @Override
198    public InputText setOnMouseMove(String inValue)
199    {
200        return (InputText) super.setOnMouseMove(inValue);
201    }
202
203    //--------------------------------------------------------------------------
204    @Override
205    public InputText setOnMouseOut(String inValue)
206    {
207        return (InputText) super.setOnMouseOut(inValue);
208    }
209
210    //--------------------------------------------------------------------------
211    @Override
212    public InputText setOnMouseOver(String inValue)
213    {
214        return (InputText) super.setOnMouseOver(inValue);
215    }
216
217    //--------------------------------------------------------------------------
218    @Override
219    public InputText setOnMouseUp(String inValue)
220    {
221        return (InputText) super.setOnMouseUp(inValue);
222    }
223
224    //--------------------------------------------------------------------------
225    @Override
226    public InputText setOnKeyDown(String inValue)
227    {
228        return (InputText) super.setOnKeyDown(inValue);
229    }
230
231    //--------------------------------------------------------------------------
232    @Override
233    public InputText setOnKeyPress(String inValue)
234    {
235        return (InputText) super.setOnKeyPress(inValue);
236    }
237
238    //--------------------------------------------------------------------------
239    @Override
240    public InputText setOnKeyUp(String inValue)
241    {
242        return (InputText) super.setOnKeyUp(inValue);
243    }
244
245
246    // Overrides for HTMLTagWithFormEvents setters to allow method chaining.
247
248    //--------------------------------------------------------------------------
249    @Override
250    public InputText setOnBlur(String inValue)
251    {
252        return (InputText) super.setOnBlur(inValue);
253    }
254
255    //--------------------------------------------------------------------------
256    @Override
257    public InputText setOnChange(String inValue)
258    {
259        return (InputText) super.setOnChange(inValue);
260    }
261
262    //--------------------------------------------------------------------------
263    @Override
264    public InputText setOnFocus(String inValue)
265    {
266        return (InputText) super.setOnFocus(inValue);
267    }
268
269}