1 /*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3 *
4 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
5 *
6 * The contents of this file are subject to the terms of either the GNU
7 * General Public License Version 2 only ("GPL") or the Common Development
8 * and Distribution License("CDDL") (collectively, the "License"). You
9 * may not use this file except in compliance with the License. You can obtain
10 * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
11 * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
12 * language governing permissions and limitations under the License.
13 *
14 * When distributing the software, include this License Header Notice in each
15 * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
16 * Sun designates this particular file as subject to the "Classpath" exception
17 * as provided by Sun in the GPL Version 2 section of the License file that
18 * accompanied this code. If applicable, add the following below the License
19 * Header, with the fields enclosed by brackets [] replaced by your own
20 * identifying information: "Portions Copyrighted [year]
21 * [name of copyright owner]"
22 *
23 * Contributor(s):
24 *
25 * If you wish your version of this file to be governed by only the CDDL or
26 * only the GPL Version 2, indicate your decision by adding "[Contributor]
27 * elects to include this software in this distribution under the [CDDL or GPL
28 * Version 2] license." If you don't indicate a single choice of license, a
29 * recipient has the option to distribute your version of this file under
30 * either the CDDL, the GPL Version 2 or to extend the choice of license to
31 * its licensees as provided above. However, if you add GPL Version 2 code
32 * and therefore, elected the GPL Version 2 license, then the option applies
33 * only if the new code is made subject to such option by the copyright
34 * holder.
35 */
36 package javax.faces.component.html;
37
38 import java.io.IOException;
39 import java.util.ArrayList;
40 import java.util.Arrays;
41 import java.util.Collection;
42 import java.util.Collections;
43 import java.util.List;
44
45 import javax.faces.context.FacesContext;
46 import javax.faces.component.behavior.ClientBehaviorHolder;
47 import javax.el.MethodExpression;
48 import javax.el.ValueExpression;
49
50
51 /*
52 * ******* GENERATED CODE - DO NOT EDIT *******
53 */
54
55
56 /**
57 * <p>Represents an HTML <code>input</code> element
58 * of type <code>text</code>.</p>
59 * <p>By default, the <code>rendererType</code> property must be set to "<code>javax.faces.Text</code>".
60 * This value can be changed by calling the <code>setRendererType()</code> method.</p>
61 */
62 public class HtmlInputText extends javax.faces.component.UIInput implements ClientBehaviorHolder {
63
64
65
66 private static final String OPTIMIZED_PACKAGE = "javax.faces.component.";
67
68 public HtmlInputText() {
69 super();
70 setRendererType("javax.faces.Text");
71 }
72
73
74 /**
75 * <p>The standard component type for this component.</p>
76 */
77 public static final String COMPONENT_TYPE = "javax.faces.HtmlInputText";
78
79
80 protected enum PropertyKeys {
81 accesskey,
82 alt,
83 autocomplete,
84 dir,
85 disabled,
86 label,
87 lang,
88 maxlength,
89 onblur,
90 onchange,
91 onclick,
92 ondblclick,
93 onfocus,
94 onkeydown,
95 onkeypress,
96 onkeyup,
97 onmousedown,
98 onmousemove,
99 onmouseout,
100 onmouseover,
101 onmouseup,
102 onselect,
103 readonly,
104 size,
105 style,
106 styleClass,
107 tabindex,
108 title,
109 ;
110 String toString;
111 PropertyKeys(String toString) { this.toString = toString; }
112 PropertyKeys() { }
113 public String toString() {
114 return ((toString != null) ? toString : super.toString());
115 }
116 }
117
118 /**
119 * <p>Return the value of the <code>accesskey</code> property.</p>
120 * <p>Contents: Access key that, when pressed, transfers focus
121 * to this element.
122 */
123 public java.lang.String getAccesskey() {
124 return (java.lang.String) getStateHelper().eval(PropertyKeys.accesskey);
125
126 }
127
128 /**
129 * <p>Set the value of the <code>accesskey</code> property.</p>
130 */
131 public void setAccesskey(java.lang.String accesskey) {
132 getStateHelper().put(PropertyKeys.accesskey, accesskey);
133 handleAttribute("accesskey", accesskey);
134 }
135
136
137 /**
138 * <p>Return the value of the <code>alt</code> property.</p>
139 * <p>Contents: Alternate textual description of the
140 * element rendered by this component.
141 */
142 public java.lang.String getAlt() {
143 return (java.lang.String) getStateHelper().eval(PropertyKeys.alt);
144
145 }
146
147 /**
148 * <p>Set the value of the <code>alt</code> property.</p>
149 */
150 public void setAlt(java.lang.String alt) {
151 getStateHelper().put(PropertyKeys.alt, alt);
152 handleAttribute("alt", alt);
153 }
154
155
156 /**
157 * <p>Return the value of the <code>autocomplete</code> property.</p>
158 * <p>Contents: If the value of this attribute is "off", render "off" as the value
159 * of the attribute. This indicates that the browser should
160 * disable its autocomplete feature for this component. This is useful for components that perform autocompletion and do not
161 * want the browser interfering. If this attribute is not set or the value
162 * is "on", render nothing.
163 */
164 public java.lang.String getAutocomplete() {
165 return (java.lang.String) getStateHelper().eval(PropertyKeys.autocomplete);
166
167 }
168
169 /**
170 * <p>Set the value of the <code>autocomplete</code> property.</p>
171 */
172 public void setAutocomplete(java.lang.String autocomplete) {
173 getStateHelper().put(PropertyKeys.autocomplete, autocomplete);
174 }
175
176
177 /**
178 * <p>Return the value of the <code>dir</code> property.</p>
179 * <p>Contents: Direction indication for text that does not inherit directionality.
180 * Valid values are "LTR" (left-to-right) and "RTL" (right-to-left).
181 */
182 public java.lang.String getDir() {
183 return (java.lang.String) getStateHelper().eval(PropertyKeys.dir);
184
185 }
186
187 /**
188 * <p>Set the value of the <code>dir</code> property.</p>
189 */
190 public void setDir(java.lang.String dir) {
191 getStateHelper().put(PropertyKeys.dir, dir);
192 handleAttribute("dir", dir);
193 }
194
195
196 /**
197 * <p>Return the value of the <code>disabled</code> property.</p>
198 * <p>Contents: Flag indicating that this element must never receive focus or
199 * be included in a subsequent submit. A value of false causes
200 * no attribute to be rendered, while a value of true causes the
201 * attribute to be rendered as disabled="disabled".
202 */
203 public boolean isDisabled() {
204 return (java.lang.Boolean) getStateHelper().eval(PropertyKeys.disabled, false);
205
206 }
207
208 /**
209 * <p>Set the value of the <code>disabled</code> property.</p>
210 */
211 public void setDisabled(boolean disabled) {
212 getStateHelper().put(PropertyKeys.disabled, disabled);
213 }
214
215
216 /**
217 * <p>Return the value of the <code>label</code> property.</p>
218 * <p>Contents: A localized user presentable name for this component.
219 */
220 public java.lang.String getLabel() {
221 return (java.lang.String) getStateHelper().eval(PropertyKeys.label);
222
223 }
224
225 /**
226 * <p>Set the value of the <code>label</code> property.</p>
227 */
228 public void setLabel(java.lang.String label) {
229 getStateHelper().put(PropertyKeys.label, label);
230 }
231
232
233 /**
234 * <p>Return the value of the <code>lang</code> property.</p>
235 * <p>Contents: Code describing the language used in the generated markup
236 * for this component.
237 */
238 public java.lang.String getLang() {
239 return (java.lang.String) getStateHelper().eval(PropertyKeys.lang);
240
241 }
242
243 /**
244 * <p>Set the value of the <code>lang</code> property.</p>
245 */
246 public void setLang(java.lang.String lang) {
247 getStateHelper().put(PropertyKeys.lang, lang);
248 handleAttribute("lang", lang);
249 }
250
251
252 /**
253 * <p>Return the value of the <code>maxlength</code> property.</p>
254 * <p>Contents: The maximum number of characters that may
255 * be entered in this field.
256 */
257 public int getMaxlength() {
258 return (java.lang.Integer) getStateHelper().eval(PropertyKeys.maxlength, Integer.MIN_VALUE);
259
260 }
261
262 /**
263 * <p>Set the value of the <code>maxlength</code> property.</p>
264 */
265 public void setMaxlength(int maxlength) {
266 getStateHelper().put(PropertyKeys.maxlength, maxlength);
267 handleAttribute("maxlength", maxlength);
268 }
269
270
271 /**
272 * <p>Return the value of the <code>onblur</code> property.</p>
273 * <p>Contents: Javascript code executed when this element loses focus.
274 */
275 public java.lang.String getOnblur() {
276 return (java.lang.String) getStateHelper().eval(PropertyKeys.onblur);
277
278 }
279
280 /**
281 * <p>Set the value of the <code>onblur</code> property.</p>
282 */
283 public void setOnblur(java.lang.String onblur) {
284 getStateHelper().put(PropertyKeys.onblur, onblur);
285 handleAttribute("onblur", onblur);
286 }
287
288
289 /**
290 * <p>Return the value of the <code>onchange</code> property.</p>
291 * <p>Contents: Javascript code executed when this element loses focus
292 * and its value has been modified since gaining focus.
293 */
294 public java.lang.String getOnchange() {
295 return (java.lang.String) getStateHelper().eval(PropertyKeys.onchange);
296
297 }
298
299 /**
300 * <p>Set the value of the <code>onchange</code> property.</p>
301 */
302 public void setOnchange(java.lang.String onchange) {
303 getStateHelper().put(PropertyKeys.onchange, onchange);
304 }
305
306
307 /**
308 * <p>Return the value of the <code>onclick</code> property.</p>
309 * <p>Contents: Javascript code executed when a pointer button is
310 * clicked over this element.
311 */
312 public java.lang.String getOnclick() {
313 return (java.lang.String) getStateHelper().eval(PropertyKeys.onclick);
314
315 }
316
317 /**
318 * <p>Set the value of the <code>onclick</code> property.</p>
319 */
320 public void setOnclick(java.lang.String onclick) {
321 getStateHelper().put(PropertyKeys.onclick, onclick);
322 handleAttribute("onclick", onclick);
323 }
324
325
326 /**
327 * <p>Return the value of the <code>ondblclick</code> property.</p>
328 * <p>Contents: Javascript code executed when a pointer button is
329 * double clicked over this element.
330 */
331 public java.lang.String getOndblclick() {
332 return (java.lang.String) getStateHelper().eval(PropertyKeys.ondblclick);
333
334 }
335
336 /**
337 * <p>Set the value of the <code>ondblclick</code> property.</p>
338 */
339 public void setOndblclick(java.lang.String ondblclick) {
340 getStateHelper().put(PropertyKeys.ondblclick, ondblclick);
341 handleAttribute("ondblclick", ondblclick);
342 }
343
344
345 /**
346 * <p>Return the value of the <code>onfocus</code> property.</p>
347 * <p>Contents: Javascript code executed when this element receives focus.
348 */
349 public java.lang.String getOnfocus() {
350 return (java.lang.String) getStateHelper().eval(PropertyKeys.onfocus);
351
352 }
353
354 /**
355 * <p>Set the value of the <code>onfocus</code> property.</p>
356 */
357 public void setOnfocus(java.lang.String onfocus) {
358 getStateHelper().put(PropertyKeys.onfocus, onfocus);
359 handleAttribute("onfocus", onfocus);
360 }
361
362
363 /**
364 * <p>Return the value of the <code>onkeydown</code> property.</p>
365 * <p>Contents: Javascript code executed when a key is
366 * pressed down over this element.
367 */
368 public java.lang.String getOnkeydown() {
369 return (java.lang.String) getStateHelper().eval(PropertyKeys.onkeydown);
370
371 }
372
373 /**
374 * <p>Set the value of the <code>onkeydown</code> property.</p>
375 */
376 public void setOnkeydown(java.lang.String onkeydown) {
377 getStateHelper().put(PropertyKeys.onkeydown, onkeydown);
378 handleAttribute("onkeydown", onkeydown);
379 }
380
381
382 /**
383 * <p>Return the value of the <code>onkeypress</code> property.</p>
384 * <p>Contents: Javascript code executed when a key is
385 * pressed and released over this element.
386 */
387 public java.lang.String getOnkeypress() {
388 return (java.lang.String) getStateHelper().eval(PropertyKeys.onkeypress);
389
390 }
391
392 /**
393 * <p>Set the value of the <code>onkeypress</code> property.</p>
394 */
395 public void setOnkeypress(java.lang.String onkeypress) {
396 getStateHelper().put(PropertyKeys.onkeypress, onkeypress);
397 handleAttribute("onkeypress", onkeypress);
398 }
399
400
401 /**
402 * <p>Return the value of the <code>onkeyup</code> property.</p>
403 * <p>Contents: Javascript code executed when a key is
404 * released over this element.
405 */
406 public java.lang.String getOnkeyup() {
407 return (java.lang.String) getStateHelper().eval(PropertyKeys.onkeyup);
408
409 }
410
411 /**
412 * <p>Set the value of the <code>onkeyup</code> property.</p>
413 */
414 public void setOnkeyup(java.lang.String onkeyup) {
415 getStateHelper().put(PropertyKeys.onkeyup, onkeyup);
416 handleAttribute("onkeyup", onkeyup);
417 }
418
419
420 /**
421 * <p>Return the value of the <code>onmousedown</code> property.</p>
422 * <p>Contents: Javascript code executed when a pointer button is
423 * pressed down over this element.
424 */
425 public java.lang.String getOnmousedown() {
426 return (java.lang.String) getStateHelper().eval(PropertyKeys.onmousedown);
427
428 }
429
430 /**
431 * <p>Set the value of the <code>onmousedown</code> property.</p>
432 */
433 public void setOnmousedown(java.lang.String onmousedown) {
434 getStateHelper().put(PropertyKeys.onmousedown, onmousedown);
435 handleAttribute("onmousedown", onmousedown);
436 }
437
438
439 /**
440 * <p>Return the value of the <code>onmousemove</code> property.</p>
441 * <p>Contents: Javascript code executed when a pointer button is
442 * moved within this element.
443 */
444 public java.lang.String getOnmousemove() {
445 return (java.lang.String) getStateHelper().eval(PropertyKeys.onmousemove);
446
447 }
448
449 /**
450 * <p>Set the value of the <code>onmousemove</code> property.</p>
451 */
452 public void setOnmousemove(java.lang.String onmousemove) {
453 getStateHelper().put(PropertyKeys.onmousemove, onmousemove);
454 handleAttribute("onmousemove", onmousemove);
455 }
456
457
458 /**
459 * <p>Return the value of the <code>onmouseout</code> property.</p>
460 * <p>Contents: Javascript code executed when a pointer button is
461 * moved away from this element.
462 */
463 public java.lang.String getOnmouseout() {
464 return (java.lang.String) getStateHelper().eval(PropertyKeys.onmouseout);
465
466 }
467
468 /**
469 * <p>Set the value of the <code>onmouseout</code> property.</p>
470 */
471 public void setOnmouseout(java.lang.String onmouseout) {
472 getStateHelper().put(PropertyKeys.onmouseout, onmouseout);
473 handleAttribute("onmouseout", onmouseout);
474 }
475
476
477 /**
478 * <p>Return the value of the <code>onmouseover</code> property.</p>
479 * <p>Contents: Javascript code executed when a pointer button is
480 * moved onto this element.
481 */
482 public java.lang.String getOnmouseover() {
483 return (java.lang.String) getStateHelper().eval(PropertyKeys.onmouseover);
484
485 }
486
487 /**
488 * <p>Set the value of the <code>onmouseover</code> property.</p>
489 */
490 public void setOnmouseover(java.lang.String onmouseover) {
491 getStateHelper().put(PropertyKeys.onmouseover, onmouseover);
492 handleAttribute("onmouseover", onmouseover);
493 }
494
495
496 /**
497 * <p>Return the value of the <code>onmouseup</code> property.</p>
498 * <p>Contents: Javascript code executed when a pointer button is
499 * released over this element.
500 */
501 public java.lang.String getOnmouseup() {
502 return (java.lang.String) getStateHelper().eval(PropertyKeys.onmouseup);
503
504 }
505
506 /**
507 * <p>Set the value of the <code>onmouseup</code> property.</p>
508 */
509 public void setOnmouseup(java.lang.String onmouseup) {
510 getStateHelper().put(PropertyKeys.onmouseup, onmouseup);
511 handleAttribute("onmouseup", onmouseup);
512 }
513
514
515 /**
516 * <p>Return the value of the <code>onselect</code> property.</p>
517 * <p>Contents: Javascript code executed when text within this
518 * element is selected by the user.
519 */
520 public java.lang.String getOnselect() {
521 return (java.lang.String) getStateHelper().eval(PropertyKeys.onselect);
522
523 }
524
525 /**
526 * <p>Set the value of the <code>onselect</code> property.</p>
527 */
528 public void setOnselect(java.lang.String onselect) {
529 getStateHelper().put(PropertyKeys.onselect, onselect);
530 handleAttribute("onselect", onselect);
531 }
532
533
534 /**
535 * <p>Return the value of the <code>readonly</code> property.</p>
536 * <p>Contents: Flag indicating that this component will prohibit changes by
537 * the user. The element may receive focus unless it has also
538 * been disabled. A value of false causes
539 * no attribute to be rendered, while a value of true causes the
540 * attribute to be rendered as readonly="readonly".
541 */
542 public boolean isReadonly() {
543 return (java.lang.Boolean) getStateHelper().eval(PropertyKeys.readonly, false);
544
545 }
546
547 /**
548 * <p>Set the value of the <code>readonly</code> property.</p>
549 */
550 public void setReadonly(boolean readonly) {
551 getStateHelper().put(PropertyKeys.readonly, readonly);
552 }
553
554
555 /**
556 * <p>Return the value of the <code>size</code> property.</p>
557 * <p>Contents: The number of characters used to determine
558 * the width of this field.
559 */
560 public int getSize() {
561 return (java.lang.Integer) getStateHelper().eval(PropertyKeys.size, Integer.MIN_VALUE);
562
563 }
564
565 /**
566 * <p>Set the value of the <code>size</code> property.</p>
567 */
568 public void setSize(int size) {
569 getStateHelper().put(PropertyKeys.size, size);
570 handleAttribute("size", size);
571 }
572
573
574 /**
575 * <p>Return the value of the <code>style</code> property.</p>
576 * <p>Contents: CSS style(s) to be applied when this component is rendered.
577 */
578 public java.lang.String getStyle() {
579 return (java.lang.String) getStateHelper().eval(PropertyKeys.style);
580
581 }
582
583 /**
584 * <p>Set the value of the <code>style</code> property.</p>
585 */
586 public void setStyle(java.lang.String style) {
587 getStateHelper().put(PropertyKeys.style, style);
588 handleAttribute("style", style);
589 }
590
591
592 /**
593 * <p>Return the value of the <code>styleClass</code> property.</p>
594 * <p>Contents: Space-separated list of CSS style class(es) to be applied when
595 * this element is rendered. This value must be passed through
596 * as the "class" attribute on generated markup.
597 */
598 public java.lang.String getStyleClass() {
599 return (java.lang.String) getStateHelper().eval(PropertyKeys.styleClass);
600
601 }
602
603 /**
604 * <p>Set the value of the <code>styleClass</code> property.</p>
605 */
606 public void setStyleClass(java.lang.String styleClass) {
607 getStateHelper().put(PropertyKeys.styleClass, styleClass);
608 }
609
610
611 /**
612 * <p>Return the value of the <code>tabindex</code> property.</p>
613 * <p>Contents: Position of this element in the tabbing order
614 * for the current document. This value must be
615 * an integer between 0 and 32767.
616 */
617 public java.lang.String getTabindex() {
618 return (java.lang.String) getStateHelper().eval(PropertyKeys.tabindex);
619
620 }
621
622 /**
623 * <p>Set the value of the <code>tabindex</code> property.</p>
624 */
625 public void setTabindex(java.lang.String tabindex) {
626 getStateHelper().put(PropertyKeys.tabindex, tabindex);
627 handleAttribute("tabindex", tabindex);
628 }
629
630
631 /**
632 * <p>Return the value of the <code>title</code> property.</p>
633 * <p>Contents: Advisory title information about markup elements generated
634 * for this component.
635 */
636 public java.lang.String getTitle() {
637 return (java.lang.String) getStateHelper().eval(PropertyKeys.title);
638
639 }
640
641 /**
642 * <p>Set the value of the <code>title</code> property.</p>
643 */
644 public void setTitle(java.lang.String title) {
645 getStateHelper().put(PropertyKeys.title, title);
646 handleAttribute("title", title);
647 }
648
649
650 private static final Collection<String> EVENT_NAMES = Collections.unmodifiableCollection(Arrays.asList("blur","change","valueChange","click","dblclick","focus","keydown","keypress","keyup","mousedown","mousemove","mouseout","mouseover","mouseup","select"));
651
652 public Collection<String> getEventNames() {
653 return EVENT_NAMES; }
654
655
656 public String getDefaultEventName() {
657 return "valueChange"; }
658
659
660 private void handleAttribute(String name, Object value) {
661 List<String> setAttributes = (List<String>) this.getAttributes().get("javax.faces.component.UIComponentBase.attributesThatAreSet");
662 if (setAttributes == null) {
663 String cname = this.getClass().getName();
664 if (cname != null && cname.startsWith(OPTIMIZED_PACKAGE)) {
665 setAttributes = new ArrayList<String>(6);
666 this.getAttributes().put("javax.faces.component.UIComponentBase.attributesThatAreSet", setAttributes);
667 }
668 }
669 if (setAttributes != null) {
670 if (value == null) {
671 ValueExpression ve = getValueExpression(name);
672 if (ve == null) {
673 setAttributes.remove(name);
674 }
675 } else if (!setAttributes.contains(name)) {
676 setAttributes.add(name);
677 }
678 }
679 }
680
681 }