1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.apache.myfaces.trinidad.component.core.input;
23
24 import java.util.Arrays;
25 import java.util.Collection;
26 import java.util.Collections;
27 import java.util.List;
28 import java.util.Map;
29 import javax.faces.component.UIComponent;
30 import javax.faces.component.behavior.ClientBehavior;
31 import javax.faces.component.behavior.ClientBehaviorHolder;
32 import org.apache.myfaces.trinidad.bean.FacesBean;
33 import org.apache.myfaces.trinidad.bean.PropertyKey;
34 import org.apache.myfaces.trinidad.component.UIXInput;
35 import org.apache.myfaces.trinidad.util.ComponentUtils;
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66 public class CoreInputNumberSpinbox extends UIXInput
67 implements ClientBehaviorHolder
68 {
69 static public final String AUTO_COMPLETE_ON = "on";
70 static public final String AUTO_COMPLETE_OFF = "off";
71 static public final String STYLE_CLASS_AFFIELD_TEXT_MARKER = "AFFieldTextMarker";
72 static public final String STYLE_CLASS_AFFIELD_TEXT_LTRMARKER = "AFFieldTextLTRMarker";
73 static public final String STYLE_CLASS_AFFIELD_NUMBER_MARKER = "AFFieldNumberMarker";
74 static public final FacesBean.Type TYPE = new FacesBean.Type(
75 UIXInput.TYPE);
76 static public final PropertyKey CONTENT_STYLE_KEY =
77 TYPE.registerKey("contentStyle", String.class);
78 static public final PropertyKey READ_ONLY_KEY =
79 TYPE.registerKey("readOnly", Boolean.class, Boolean.FALSE);
80 static public final PropertyKey DISABLED_KEY =
81 TYPE.registerKey("disabled", Boolean.class, Boolean.FALSE);
82 static public final PropertyKey AUTO_COMPLETE_KEY =
83 TYPE.registerKey("autoComplete", String.class, "on");
84 static public final PropertyKey SHORT_DESC_KEY =
85 TYPE.registerKey("shortDesc", String.class);
86 static public final PropertyKey PARTIAL_TRIGGERS_KEY =
87 TYPE.registerKey("partialTriggers", String[].class);
88 static public final PropertyKey LABEL_KEY =
89 TYPE.registerKey("label", String.class);
90 static public final PropertyKey SIMPLE_KEY =
91 TYPE.registerKey("simple", Boolean.class, Boolean.FALSE);
92 static public final PropertyKey ONCHANGE_KEY =
93 TYPE.registerKey("onchange", String.class);
94 static public final PropertyKey ONCLICK_KEY =
95 TYPE.registerKey("onclick", String.class);
96 static public final PropertyKey ONDBLCLICK_KEY =
97 TYPE.registerKey("ondblclick", String.class);
98 static public final PropertyKey ONMOUSEDOWN_KEY =
99 TYPE.registerKey("onmousedown", String.class);
100 static public final PropertyKey ONMOUSEUP_KEY =
101 TYPE.registerKey("onmouseup", String.class);
102 static public final PropertyKey ONMOUSEOVER_KEY =
103 TYPE.registerKey("onmouseover", String.class);
104 static public final PropertyKey ONMOUSEMOVE_KEY =
105 TYPE.registerKey("onmousemove", String.class);
106 static public final PropertyKey ONMOUSEOUT_KEY =
107 TYPE.registerKey("onmouseout", String.class);
108 static public final PropertyKey ONKEYPRESS_KEY =
109 TYPE.registerKey("onkeypress", String.class);
110 static public final PropertyKey ONKEYDOWN_KEY =
111 TYPE.registerKey("onkeydown", String.class);
112 static public final PropertyKey ONKEYUP_KEY =
113 TYPE.registerKey("onkeyup", String.class);
114 static public final PropertyKey ONBLUR_KEY =
115 TYPE.registerKey("onblur", String.class);
116 static public final PropertyKey ONFOCUS_KEY =
117 TYPE.registerKey("onfocus", String.class);
118 static public final PropertyKey STYLE_CLASS_KEY =
119 TYPE.registerKey("styleClass", String.class);
120 static public final PropertyKey INLINE_STYLE_KEY =
121 TYPE.registerKey("inlineStyle", String.class);
122 static public final PropertyKey SHOW_REQUIRED_KEY =
123 TYPE.registerKey("showRequired", Boolean.class, Boolean.FALSE);
124 static public final PropertyKey COLUMNS_KEY =
125 TYPE.registerKey("columns", Integer.class, Integer.valueOf(1));
126 static public final PropertyKey MAXIMUM_KEY =
127 TYPE.registerKey("maximum", Integer.class, Integer.valueOf(2147483647));
128 static public final PropertyKey MINIMUM_KEY =
129 TYPE.registerKey("minimum", Integer.class, Integer.valueOf(1));
130 static public final PropertyKey STEP_SIZE_KEY =
131 TYPE.registerKey("stepSize", Integer.class, Integer.valueOf(1));
132 static public final PropertyKey ONSELECT_KEY =
133 TYPE.registerKey("onselect", String.class);
134 static public final PropertyKey ACCESS_KEY_KEY =
135 TYPE.registerKey("accessKey", Character.class);
136 static public final PropertyKey AUTO_SUBMIT_KEY =
137 TYPE.registerKey("autoSubmit", Boolean.class, Boolean.FALSE);
138 static public final String HELP_FACET = "help";
139
140 static public final String COMPONENT_FAMILY =
141 "org.apache.myfaces.trinidad.Input";
142 static public final String COMPONENT_TYPE =
143 "org.apache.myfaces.trinidad.CoreInputNumberSpinbox";
144
145 private final static Collection<String> _EVENT_NAMES = Collections.unmodifiableCollection(
146 Arrays.asList(
147 "change", "click", "dblclick", "mousedown", "mouseup", "mouseover",
148 "mousemove", "mouseout", "keypress", "keydown", "keyup", "focus",
149 "blur", "select", "valueChange"
150 ));
151
152
153
154
155 public CoreInputNumberSpinbox()
156 {
157 super("org.apache.myfaces.trinidad.NumberSpinbox");
158 }
159
160
161
162
163 final public UIComponent getHelp()
164 {
165 return getFacet(HELP_FACET);
166 }
167
168
169
170
171 @SuppressWarnings("unchecked")
172 final public void setHelp(UIComponent helpFacet)
173 {
174 getFacets().put(HELP_FACET, helpFacet);
175 }
176
177
178
179
180
181
182 final public String getContentStyle()
183 {
184 return ComponentUtils.resolveString(getProperty(CONTENT_STYLE_KEY));
185 }
186
187
188
189
190
191
192 final public void setContentStyle(String contentStyle)
193 {
194 setProperty(CONTENT_STYLE_KEY, (contentStyle));
195 }
196
197
198
199
200
201
202 final public boolean isReadOnly()
203 {
204 return ComponentUtils.resolveBoolean(getProperty(READ_ONLY_KEY), false);
205 }
206
207
208
209
210
211
212 final public void setReadOnly(boolean readOnly)
213 {
214 setProperty(READ_ONLY_KEY, readOnly ? Boolean.TRUE : Boolean.FALSE);
215 }
216
217
218
219
220
221
222 final public boolean isDisabled()
223 {
224 return ComponentUtils.resolveBoolean(getProperty(DISABLED_KEY), false);
225 }
226
227
228
229
230
231
232 final public void setDisabled(boolean disabled)
233 {
234 setProperty(DISABLED_KEY, disabled ? Boolean.TRUE : Boolean.FALSE);
235 }
236
237
238
239
240
241
242
243 final public String getAutoComplete()
244 {
245 return ComponentUtils.resolveString(getProperty(AUTO_COMPLETE_KEY), "on");
246 }
247
248
249
250
251
252
253
254 final public void setAutoComplete(String autoComplete)
255 {
256 setProperty(AUTO_COMPLETE_KEY, (autoComplete));
257 }
258
259
260
261
262
263
264
265 final public String getShortDesc()
266 {
267 return ComponentUtils.resolveString(getProperty(SHORT_DESC_KEY));
268 }
269
270
271
272
273
274
275
276 final public void setShortDesc(String shortDesc)
277 {
278 setProperty(SHORT_DESC_KEY, (shortDesc));
279 }
280
281
282
283
284
285
286
287
288
289 final public String[] getPartialTriggers()
290 {
291 return (String[])getProperty(PARTIAL_TRIGGERS_KEY);
292 }
293
294
295
296
297
298
299
300
301
302 final public void setPartialTriggers(String[] partialTriggers)
303 {
304 setProperty(PARTIAL_TRIGGERS_KEY, (partialTriggers));
305 }
306
307
308
309
310
311
312 final public String getLabel()
313 {
314 return ComponentUtils.resolveString(getProperty(LABEL_KEY));
315 }
316
317
318
319
320
321
322 final public void setLabel(String label)
323 {
324 setProperty(LABEL_KEY, (label));
325 }
326
327
328
329
330
331
332
333
334
335
336 final public boolean isSimple()
337 {
338 return ComponentUtils.resolveBoolean(getProperty(SIMPLE_KEY), false);
339 }
340
341
342
343
344
345
346
347
348
349
350 final public void setSimple(boolean simple)
351 {
352 setProperty(SIMPLE_KEY, simple ? Boolean.TRUE : Boolean.FALSE);
353 }
354
355
356
357
358
359
360 final public String getOnchange()
361 {
362 return ComponentUtils.resolveString(getProperty(ONCHANGE_KEY));
363 }
364
365
366
367
368
369
370 final public void setOnchange(String onchange)
371 {
372 setProperty(ONCHANGE_KEY, (onchange));
373 }
374
375
376
377
378
379
380 final public String getOnclick()
381 {
382 return ComponentUtils.resolveString(getProperty(ONCLICK_KEY));
383 }
384
385
386
387
388
389
390 final public void setOnclick(String onclick)
391 {
392 setProperty(ONCLICK_KEY, (onclick));
393 }
394
395
396
397
398
399
400 final public String getOndblclick()
401 {
402 return ComponentUtils.resolveString(getProperty(ONDBLCLICK_KEY));
403 }
404
405
406
407
408
409
410 final public void setOndblclick(String ondblclick)
411 {
412 setProperty(ONDBLCLICK_KEY, (ondblclick));
413 }
414
415
416
417
418
419
420 final public String getOnmousedown()
421 {
422 return ComponentUtils.resolveString(getProperty(ONMOUSEDOWN_KEY));
423 }
424
425
426
427
428
429
430 final public void setOnmousedown(String onmousedown)
431 {
432 setProperty(ONMOUSEDOWN_KEY, (onmousedown));
433 }
434
435
436
437
438
439
440 final public String getOnmouseup()
441 {
442 return ComponentUtils.resolveString(getProperty(ONMOUSEUP_KEY));
443 }
444
445
446
447
448
449
450 final public void setOnmouseup(String onmouseup)
451 {
452 setProperty(ONMOUSEUP_KEY, (onmouseup));
453 }
454
455
456
457
458
459
460 final public String getOnmouseover()
461 {
462 return ComponentUtils.resolveString(getProperty(ONMOUSEOVER_KEY));
463 }
464
465
466
467
468
469
470 final public void setOnmouseover(String onmouseover)
471 {
472 setProperty(ONMOUSEOVER_KEY, (onmouseover));
473 }
474
475
476
477
478
479
480 final public String getOnmousemove()
481 {
482 return ComponentUtils.resolveString(getProperty(ONMOUSEMOVE_KEY));
483 }
484
485
486
487
488
489
490 final public void setOnmousemove(String onmousemove)
491 {
492 setProperty(ONMOUSEMOVE_KEY, (onmousemove));
493 }
494
495
496
497
498
499
500 final public String getOnmouseout()
501 {
502 return ComponentUtils.resolveString(getProperty(ONMOUSEOUT_KEY));
503 }
504
505
506
507
508
509
510 final public void setOnmouseout(String onmouseout)
511 {
512 setProperty(ONMOUSEOUT_KEY, (onmouseout));
513 }
514
515
516
517
518
519
520 final public String getOnkeypress()
521 {
522 return ComponentUtils.resolveString(getProperty(ONKEYPRESS_KEY));
523 }
524
525
526
527
528
529
530 final public void setOnkeypress(String onkeypress)
531 {
532 setProperty(ONKEYPRESS_KEY, (onkeypress));
533 }
534
535
536
537
538
539
540 final public String getOnkeydown()
541 {
542 return ComponentUtils.resolveString(getProperty(ONKEYDOWN_KEY));
543 }
544
545
546
547
548
549
550 final public void setOnkeydown(String onkeydown)
551 {
552 setProperty(ONKEYDOWN_KEY, (onkeydown));
553 }
554
555
556
557
558
559
560 final public String getOnkeyup()
561 {
562 return ComponentUtils.resolveString(getProperty(ONKEYUP_KEY));
563 }
564
565
566
567
568
569
570 final public void setOnkeyup(String onkeyup)
571 {
572 setProperty(ONKEYUP_KEY, (onkeyup));
573 }
574
575
576
577
578
579
580 final public String getOnblur()
581 {
582 return ComponentUtils.resolveString(getProperty(ONBLUR_KEY));
583 }
584
585
586
587
588
589
590 final public void setOnblur(String onblur)
591 {
592 setProperty(ONBLUR_KEY, (onblur));
593 }
594
595
596
597
598
599
600 final public String getOnfocus()
601 {
602 return ComponentUtils.resolveString(getProperty(ONFOCUS_KEY));
603 }
604
605
606
607
608
609
610 final public void setOnfocus(String onfocus)
611 {
612 setProperty(ONFOCUS_KEY, (onfocus));
613 }
614
615
616
617
618
619
620
621
622
623
624 final public String getStyleClass()
625 {
626 return ComponentUtils.resolveString(getProperty(STYLE_CLASS_KEY));
627 }
628
629
630
631
632
633
634
635
636
637
638 final public void setStyleClass(String styleClass)
639 {
640 setProperty(STYLE_CLASS_KEY, (styleClass));
641 }
642
643
644
645
646
647
648 final public String getInlineStyle()
649 {
650 return ComponentUtils.resolveString(getProperty(INLINE_STYLE_KEY));
651 }
652
653
654
655
656
657
658 final public void setInlineStyle(String inlineStyle)
659 {
660 setProperty(INLINE_STYLE_KEY, (inlineStyle));
661 }
662
663
664
665
666
667
668
669 final public boolean isShowRequired()
670 {
671 return ComponentUtils.resolveBoolean(getProperty(SHOW_REQUIRED_KEY), false);
672 }
673
674
675
676
677
678
679
680 final public void setShowRequired(boolean showRequired)
681 {
682 setProperty(SHOW_REQUIRED_KEY, showRequired ? Boolean.TRUE : Boolean.FALSE);
683 }
684
685
686
687
688
689
690
691
692
693 final public int getColumns()
694 {
695 return ComponentUtils.resolveInteger(getProperty(COLUMNS_KEY), 1);
696 }
697
698
699
700
701
702
703
704
705
706 final public void setColumns(int columns)
707 {
708 setProperty(COLUMNS_KEY, Integer.valueOf(columns));
709 }
710
711
712
713
714
715
716 final public int getMaximum()
717 {
718 return ComponentUtils.resolveInteger(getProperty(MAXIMUM_KEY), 2147483647);
719 }
720
721
722
723
724
725
726 final public void setMaximum(int maximum)
727 {
728 setProperty(MAXIMUM_KEY, Integer.valueOf(maximum));
729 }
730
731
732
733
734
735
736 final public int getMinimum()
737 {
738 return ComponentUtils.resolveInteger(getProperty(MINIMUM_KEY), 1);
739 }
740
741
742
743
744
745
746 final public void setMinimum(int minimum)
747 {
748 setProperty(MINIMUM_KEY, Integer.valueOf(minimum));
749 }
750
751
752
753
754
755
756 final public int getStepSize()
757 {
758 return ComponentUtils.resolveInteger(getProperty(STEP_SIZE_KEY), 1);
759 }
760
761
762
763
764
765
766 final public void setStepSize(int stepSize)
767 {
768 setProperty(STEP_SIZE_KEY, Integer.valueOf(stepSize));
769 }
770
771
772
773
774
775
776 final public String getOnselect()
777 {
778 return ComponentUtils.resolveString(getProperty(ONSELECT_KEY));
779 }
780
781
782
783
784
785
786 final public void setOnselect(String onselect)
787 {
788 setProperty(ONSELECT_KEY, (onselect));
789 }
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808 final public char getAccessKey()
809 {
810 return ComponentUtils.resolveCharacter((Character)getProperty(ACCESS_KEY_KEY));
811 }
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830 final public void setAccessKey(char accessKey)
831 {
832 setProperty(ACCESS_KEY_KEY, Character.valueOf(accessKey));
833 }
834
835
836
837
838
839
840
841
842 final public boolean isAutoSubmit()
843 {
844 return ComponentUtils.resolveBoolean(getProperty(AUTO_SUBMIT_KEY), false);
845 }
846
847
848
849
850
851
852
853
854 final public void setAutoSubmit(boolean autoSubmit)
855 {
856 setProperty(AUTO_SUBMIT_KEY, autoSubmit ? Boolean.TRUE : Boolean.FALSE);
857 }
858
859 @Override
860 public String getDefaultEventName()
861 {
862 return "change";
863 }
864
865 @Override
866 public Collection<String> getEventNames()
867 {
868 return _EVENT_NAMES;
869 }
870
871 @Override
872 public Map<String, List<ClientBehavior>> getClientBehaviors()
873 {
874 return super.getClientBehaviors();
875 }
876
877 @Override
878 public void addClientBehavior(
879 String eventName,
880 ClientBehavior behavior)
881 {
882 super.addClientBehavior(eventName, behavior);
883 }
884
885 @Override
886 public String getFamily()
887 {
888 return COMPONENT_FAMILY;
889 }
890
891 @Override
892 protected FacesBean.Type getBeanType()
893 {
894 return TYPE;
895 }
896
897
898
899
900 protected CoreInputNumberSpinbox(
901 String rendererType
902 )
903 {
904 super(rendererType);
905 }
906
907 static
908 {
909 TYPE.lockAndRegister("org.apache.myfaces.trinidad.Input","org.apache.myfaces.trinidad.NumberSpinbox");
910 }
911 }