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.html;
23
24 import java.util.ArrayDeque;
25 import java.util.Arrays;
26 import java.util.Collection;
27 import java.util.Collections;
28 import java.util.List;
29 import java.util.Map;
30 import java.util.Queue;
31 import javax.faces.component.behavior.ClientBehavior;
32 import javax.faces.component.behavior.ClientBehaviorHolder;
33 import javax.faces.context.FacesContext;
34 import org.apache.myfaces.trinidad.bean.FacesBean;
35 import org.apache.myfaces.trinidad.bean.PropertyKey;
36 import org.apache.myfaces.trinidad.component.UIXComponentBase;
37 import org.apache.myfaces.trinidad.context.ComponentContextManager;
38 import org.apache.myfaces.trinidad.context.RequestContext;
39 import org.apache.myfaces.trinidad.context.SuspendedContextChanges;
40 import org.apache.myfaces.trinidad.util.ComponentUtils;
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
67
68
69
70 public class HtmlBody extends UIXComponentBase
71 implements ClientBehaviorHolder
72 {
73 static public final FacesBean.Type TYPE = new FacesBean.Type(
74 UIXComponentBase.TYPE);
75 static public final PropertyKey FIRST_CLICK_PASSED_KEY =
76 TYPE.registerKey("firstClickPassed", Boolean.class, Boolean.FALSE);
77 static public final PropertyKey SHORT_DESC_KEY =
78 TYPE.registerKey("shortDesc", String.class);
79 static public final PropertyKey PARTIAL_TRIGGERS_KEY =
80 TYPE.registerKey("partialTriggers", String[].class, null, 0, PropertyKey.Mutable.RARELY);
81 static public final PropertyKey ONCLICK_KEY =
82 TYPE.registerKey("onclick", String.class);
83 static public final PropertyKey ONDBLCLICK_KEY =
84 TYPE.registerKey("ondblclick", String.class);
85 static public final PropertyKey ONMOUSEDOWN_KEY =
86 TYPE.registerKey("onmousedown", String.class);
87 static public final PropertyKey ONMOUSEUP_KEY =
88 TYPE.registerKey("onmouseup", String.class);
89 static public final PropertyKey ONMOUSEOVER_KEY =
90 TYPE.registerKey("onmouseover", String.class);
91 static public final PropertyKey ONMOUSEMOVE_KEY =
92 TYPE.registerKey("onmousemove", String.class);
93 static public final PropertyKey ONMOUSEOUT_KEY =
94 TYPE.registerKey("onmouseout", String.class);
95 static public final PropertyKey ONKEYPRESS_KEY =
96 TYPE.registerKey("onkeypress", String.class);
97 static public final PropertyKey ONKEYDOWN_KEY =
98 TYPE.registerKey("onkeydown", String.class);
99 static public final PropertyKey ONKEYUP_KEY =
100 TYPE.registerKey("onkeyup", String.class);
101 static public final PropertyKey STYLE_CLASS_KEY =
102 TYPE.registerKey("styleClass", String.class);
103 static public final PropertyKey INLINE_STYLE_KEY =
104 TYPE.registerKey("inlineStyle", String.class);
105 static public final PropertyKey ONLOAD_KEY =
106 TYPE.registerKey("onload", String.class);
107 static public final PropertyKey ONUNLOAD_KEY =
108 TYPE.registerKey("onunload", String.class);
109 static public final PropertyKey INITIAL_FOCUS_ID_KEY =
110 TYPE.registerKey("initialFocusId", String.class);
111
112 static public final String COMPONENT_FAMILY =
113 "org.apache.myfaces.trinidad.Body";
114 static public final String COMPONENT_TYPE =
115 "org.apache.myfaces.trinidad.HtmlBody";
116
117 private final static Collection<String> _EVENT_NAMES = Collections.unmodifiableCollection(
118 Arrays.asList(
119 "click", "dblclick", "mousedown", "mouseup", "mouseover", "mousemove",
120 "mouseout", "keypress", "keydown", "keyup", "load", "unload"
121 ));
122
123
124
125
126 public HtmlBody()
127 {
128 super("org.apache.myfaces.trinidad.Body");
129 }
130
131
132
133
134
135
136 @Override
137 protected void setupVisitingContext(FacesContext facesContext)
138 {
139 ComponentContextManager ctxMgr = RequestContext.getCurrentInstance()
140 .getComponentContextManager();
141
142
143
144 SuspendedContextChanges suspendedChanges = ctxMgr.suspend(facesContext);
145
146 Map<String, Object> reqMap = facesContext.getExternalContext().getRequestMap();
147 @SuppressWarnings("unchecked")
148 Queue<SuspendedContextChanges> suspendedChangesQueue = (Queue<SuspendedContextChanges>)
149 reqMap.get(_SUSPENDED_CHANGES_KEY);
150 if (suspendedChangesQueue == null)
151 {
152 suspendedChangesQueue = Collections.asLifoQueue(new ArrayDeque<SuspendedContextChanges>());
153 reqMap.put(_SUSPENDED_CHANGES_KEY, suspendedChangesQueue);
154 }
155
156 suspendedChangesQueue.offer(suspendedChanges);
157
158 super.setupVisitingContext(facesContext);
159 }
160
161
162
163
164
165
166
167 @Override
168 protected void tearDownVisitingContext(FacesContext facesContext)
169 {
170 super.tearDownVisitingContext(facesContext);
171
172 ComponentContextManager ctxMgr = RequestContext.getCurrentInstance()
173 .getComponentContextManager();
174 Map<String, Object> reqMap = facesContext.getExternalContext().getRequestMap();
175 @SuppressWarnings("unchecked")
176 Queue<SuspendedContextChanges> suspendedChangesQueue = (Queue<SuspendedContextChanges>)
177 reqMap.get(_SUSPENDED_CHANGES_KEY);
178 SuspendedContextChanges changes = suspendedChangesQueue.poll();
179 ctxMgr.resume(facesContext, changes);
180 }
181
182 private final static String _SUSPENDED_CHANGES_KEY = HtmlBody.class.getName() +
183 ".SUSPENDED_CHANGES";
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201 final public boolean isFirstClickPassed()
202 {
203 return ComponentUtils.resolveBoolean(getProperty(FIRST_CLICK_PASSED_KEY), false);
204 }
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222 final public void setFirstClickPassed(boolean firstClickPassed)
223 {
224 setProperty(FIRST_CLICK_PASSED_KEY, firstClickPassed ? Boolean.TRUE : Boolean.FALSE);
225 }
226
227
228
229
230
231
232
233 final public String getShortDesc()
234 {
235 return ComponentUtils.resolveString(getProperty(SHORT_DESC_KEY));
236 }
237
238
239
240
241
242
243
244 final public void setShortDesc(String shortDesc)
245 {
246 setProperty(SHORT_DESC_KEY, (shortDesc));
247 }
248
249
250
251
252
253
254
255
256
257 final public String[] getPartialTriggers()
258 {
259 return (String[])getProperty(PARTIAL_TRIGGERS_KEY);
260 }
261
262
263
264
265
266
267
268
269
270 final public void setPartialTriggers(String[] partialTriggers)
271 {
272 setProperty(PARTIAL_TRIGGERS_KEY, (partialTriggers));
273 }
274
275
276
277
278
279
280 final public String getOnclick()
281 {
282 return ComponentUtils.resolveString(getProperty(ONCLICK_KEY));
283 }
284
285
286
287
288
289
290 final public void setOnclick(String onclick)
291 {
292 setProperty(ONCLICK_KEY, (onclick));
293 }
294
295
296
297
298
299
300 final public String getOndblclick()
301 {
302 return ComponentUtils.resolveString(getProperty(ONDBLCLICK_KEY));
303 }
304
305
306
307
308
309
310 final public void setOndblclick(String ondblclick)
311 {
312 setProperty(ONDBLCLICK_KEY, (ondblclick));
313 }
314
315
316
317
318
319
320 final public String getOnmousedown()
321 {
322 return ComponentUtils.resolveString(getProperty(ONMOUSEDOWN_KEY));
323 }
324
325
326
327
328
329
330 final public void setOnmousedown(String onmousedown)
331 {
332 setProperty(ONMOUSEDOWN_KEY, (onmousedown));
333 }
334
335
336
337
338
339
340 final public String getOnmouseup()
341 {
342 return ComponentUtils.resolveString(getProperty(ONMOUSEUP_KEY));
343 }
344
345
346
347
348
349
350 final public void setOnmouseup(String onmouseup)
351 {
352 setProperty(ONMOUSEUP_KEY, (onmouseup));
353 }
354
355
356
357
358
359
360 final public String getOnmouseover()
361 {
362 return ComponentUtils.resolveString(getProperty(ONMOUSEOVER_KEY));
363 }
364
365
366
367
368
369
370 final public void setOnmouseover(String onmouseover)
371 {
372 setProperty(ONMOUSEOVER_KEY, (onmouseover));
373 }
374
375
376
377
378
379
380 final public String getOnmousemove()
381 {
382 return ComponentUtils.resolveString(getProperty(ONMOUSEMOVE_KEY));
383 }
384
385
386
387
388
389
390 final public void setOnmousemove(String onmousemove)
391 {
392 setProperty(ONMOUSEMOVE_KEY, (onmousemove));
393 }
394
395
396
397
398
399
400 final public String getOnmouseout()
401 {
402 return ComponentUtils.resolveString(getProperty(ONMOUSEOUT_KEY));
403 }
404
405
406
407
408
409
410 final public void setOnmouseout(String onmouseout)
411 {
412 setProperty(ONMOUSEOUT_KEY, (onmouseout));
413 }
414
415
416
417
418
419
420 final public String getOnkeypress()
421 {
422 return ComponentUtils.resolveString(getProperty(ONKEYPRESS_KEY));
423 }
424
425
426
427
428
429
430 final public void setOnkeypress(String onkeypress)
431 {
432 setProperty(ONKEYPRESS_KEY, (onkeypress));
433 }
434
435
436
437
438
439
440 final public String getOnkeydown()
441 {
442 return ComponentUtils.resolveString(getProperty(ONKEYDOWN_KEY));
443 }
444
445
446
447
448
449
450 final public void setOnkeydown(String onkeydown)
451 {
452 setProperty(ONKEYDOWN_KEY, (onkeydown));
453 }
454
455
456
457
458
459
460 final public String getOnkeyup()
461 {
462 return ComponentUtils.resolveString(getProperty(ONKEYUP_KEY));
463 }
464
465
466
467
468
469
470 final public void setOnkeyup(String onkeyup)
471 {
472 setProperty(ONKEYUP_KEY, (onkeyup));
473 }
474
475
476
477
478
479
480 final public String getStyleClass()
481 {
482 return ComponentUtils.resolveString(getProperty(STYLE_CLASS_KEY));
483 }
484
485
486
487
488
489
490 final public void setStyleClass(String styleClass)
491 {
492 setProperty(STYLE_CLASS_KEY, (styleClass));
493 }
494
495
496
497
498
499
500 final public String getInlineStyle()
501 {
502 return ComponentUtils.resolveString(getProperty(INLINE_STYLE_KEY));
503 }
504
505
506
507
508
509
510 final public void setInlineStyle(String inlineStyle)
511 {
512 setProperty(INLINE_STYLE_KEY, (inlineStyle));
513 }
514
515
516
517
518
519
520 final public String getOnload()
521 {
522 return ComponentUtils.resolveString(getProperty(ONLOAD_KEY));
523 }
524
525
526
527
528
529
530 final public void setOnload(String onload)
531 {
532 setProperty(ONLOAD_KEY, (onload));
533 }
534
535
536
537
538
539
540 final public String getOnunload()
541 {
542 return ComponentUtils.resolveString(getProperty(ONUNLOAD_KEY));
543 }
544
545
546
547
548
549
550 final public void setOnunload(String onunload)
551 {
552 setProperty(ONUNLOAD_KEY, (onunload));
553 }
554
555
556
557
558
559
560
561
562 final public String getInitialFocusId()
563 {
564 return ComponentUtils.resolveString(getProperty(INITIAL_FOCUS_ID_KEY));
565 }
566
567
568
569
570
571
572
573
574 final public void setInitialFocusId(String initialFocusId)
575 {
576 setProperty(INITIAL_FOCUS_ID_KEY, (initialFocusId));
577 }
578
579 @Override
580 public String getDefaultEventName()
581 {
582 return "load";
583 }
584
585 @Override
586 public Collection<String> getEventNames()
587 {
588 return _EVENT_NAMES;
589 }
590
591 @Override
592 public Map<String, List<ClientBehavior>> getClientBehaviors()
593 {
594 return super.getClientBehaviors();
595 }
596
597 @Override
598 public void addClientBehavior(
599 String eventName,
600 ClientBehavior behavior)
601 {
602 super.addClientBehavior(eventName, behavior);
603 }
604
605 @Override
606 public String getFamily()
607 {
608 return COMPONENT_FAMILY;
609 }
610
611 @Override
612 protected FacesBean.Type getBeanType()
613 {
614 return TYPE;
615 }
616
617
618
619
620 protected HtmlBody(
621 String rendererType
622 )
623 {
624 super(rendererType);
625 }
626
627 static
628 {
629 TYPE.lockAndRegister("org.apache.myfaces.trinidad.Body","org.apache.myfaces.trinidad.Body");
630 }
631 }