1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package javax.faces.component; |
20 | |
|
21 | |
import java.io.IOException; |
22 | |
import java.io.Serializable; |
23 | |
import java.lang.reflect.Array; |
24 | |
import java.util.ArrayList; |
25 | |
import java.util.Collection; |
26 | |
import java.util.Collections; |
27 | |
import java.util.HashMap; |
28 | |
import java.util.Iterator; |
29 | |
import java.util.List; |
30 | |
import java.util.Map; |
31 | |
import java.util.logging.Level; |
32 | |
import java.util.logging.Logger; |
33 | |
|
34 | |
import javax.el.ValueExpression; |
35 | |
import javax.faces.FacesException; |
36 | |
import javax.faces.component.behavior.Behavior; |
37 | |
import javax.faces.component.behavior.ClientBehavior; |
38 | |
import javax.faces.component.visit.VisitCallback; |
39 | |
import javax.faces.component.visit.VisitContext; |
40 | |
import javax.faces.context.FacesContext; |
41 | |
import javax.faces.el.ValueBinding; |
42 | |
import javax.faces.event.AbortProcessingException; |
43 | |
import javax.faces.event.BehaviorEvent; |
44 | |
import javax.faces.event.FacesEvent; |
45 | |
import javax.faces.event.FacesListener; |
46 | |
import javax.faces.event.PostAddToViewEvent; |
47 | |
import javax.faces.event.PreRemoveFromViewEvent; |
48 | |
import javax.faces.event.PreRenderComponentEvent; |
49 | |
import javax.faces.event.SystemEvent; |
50 | |
import javax.faces.event.SystemEventListener; |
51 | |
import javax.faces.render.RenderKit; |
52 | |
import javax.faces.render.Renderer; |
53 | |
import javax.faces.view.Location; |
54 | |
|
55 | |
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFComponent; |
56 | |
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFJspProperty; |
57 | |
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFProperty; |
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | |
|
66 | |
|
67 | |
|
68 | |
|
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | |
|
74 | |
|
75 | |
@JSFComponent(type = "javax.faces.ComponentBase", family = "javax.faces.ComponentBase", desc = "base component when all components must inherit", tagClass = "javax.faces.webapp.UIComponentELTag", configExcluded = true) |
76 | |
@JSFJspProperty(name = "binding", returnType = "javax.faces.component.UIComponent", longDesc = "Identifies a backing bean property (of type UIComponent or appropriate subclass) to bind to this component instance. This value must be an EL expression.", desc = "backing bean property to bind to this component instance") |
77 | |
public abstract class UIComponentBase extends UIComponent |
78 | |
{ |
79 | |
|
80 | 0 | private static Logger log = Logger.getLogger(UIComponentBase.class.getName()); |
81 | |
|
82 | 0 | private static final ThreadLocal<StringBuilder> _STRING_BUILDER = new ThreadLocal<StringBuilder>(); |
83 | |
|
84 | 0 | private static final Iterator<UIComponent> _EMPTY_UICOMPONENT_ITERATOR = new _EmptyIterator<UIComponent>(); |
85 | |
|
86 | 0 | private _ComponentAttributesMap _attributesMap = null; |
87 | 0 | private List<UIComponent> _childrenList = null; |
88 | 0 | private Map<String, UIComponent> _facetMap = null; |
89 | 0 | private _DeltaList<FacesListener> _facesListeners = null; |
90 | 0 | private String _clientId = null; |
91 | 0 | private String _id = null; |
92 | 0 | private UIComponent _parent = null; |
93 | 0 | private boolean _transient = false; |
94 | |
|
95 | |
|
96 | |
|
97 | |
|
98 | |
|
99 | |
|
100 | |
|
101 | |
|
102 | |
|
103 | |
|
104 | |
|
105 | |
|
106 | |
|
107 | |
|
108 | |
|
109 | |
|
110 | 0 | private Map<String, List<ClientBehavior>> _behaviorsMap = null; |
111 | 0 | private transient Map<String, List<ClientBehavior>> _unmodifiableBehaviorsMap = null; |
112 | |
|
113 | |
private transient FacesContext _facesContext; |
114 | |
|
115 | |
public UIComponentBase() |
116 | 0 | { |
117 | 0 | } |
118 | |
|
119 | |
|
120 | |
|
121 | |
|
122 | |
|
123 | |
|
124 | |
@Override |
125 | |
public void setValueBinding(String name, ValueBinding binding) |
126 | |
{ |
127 | 0 | setValueExpression(name, binding == null ? null : new _ValueBindingToValueExpression(binding)); |
128 | 0 | } |
129 | |
|
130 | |
|
131 | |
|
132 | |
|
133 | |
|
134 | |
|
135 | |
|
136 | |
|
137 | |
|
138 | |
|
139 | |
|
140 | |
|
141 | |
|
142 | |
|
143 | |
|
144 | |
|
145 | |
|
146 | |
|
147 | |
@Override |
148 | |
public void setId(String id) |
149 | |
{ |
150 | 0 | isIdValid(id); |
151 | 0 | _id = id; |
152 | 0 | _clientId = null; |
153 | 0 | } |
154 | |
|
155 | |
|
156 | |
|
157 | |
|
158 | |
|
159 | |
|
160 | |
|
161 | |
|
162 | |
@Override |
163 | |
public void setParent(UIComponent parent) |
164 | |
{ |
165 | |
|
166 | 0 | if (parent == null) |
167 | |
{ |
168 | |
|
169 | 0 | if (_parent != null && _parent.isInView()) |
170 | |
{ |
171 | |
|
172 | |
|
173 | |
|
174 | 0 | _publishPreRemoveFromViewEvent(getFacesContext(), this); |
175 | |
} |
176 | 0 | _parent = parent; |
177 | |
} else { |
178 | 0 | _parent = parent; |
179 | 0 | if (parent.isInView()) |
180 | |
{ |
181 | |
|
182 | |
|
183 | |
|
184 | |
|
185 | |
|
186 | 0 | _publishPostAddToViewEvent(getFacesContext(), this); |
187 | |
} |
188 | |
} |
189 | 0 | } |
190 | |
|
191 | |
|
192 | |
|
193 | |
|
194 | |
|
195 | |
|
196 | |
|
197 | |
|
198 | |
private static void _publishPostAddToViewEvent(FacesContext context, UIComponent component) |
199 | |
{ |
200 | 0 | component.setInView(true); |
201 | 0 | context.getApplication().publishEvent(context, PostAddToViewEvent.class, UIComponent.class, component); |
202 | |
|
203 | 0 | if (component.getChildCount() > 0) |
204 | |
{ |
205 | |
|
206 | |
|
207 | |
|
208 | |
|
209 | |
|
210 | 0 | List<UIComponent> children = component.getChildren(); |
211 | 0 | UIComponent child = null; |
212 | 0 | UIComponent currentChild = null; |
213 | 0 | int i = 0; |
214 | 0 | while (i < children.size()) |
215 | |
{ |
216 | 0 | child = children.get(i); |
217 | |
|
218 | |
|
219 | |
do |
220 | |
{ |
221 | 0 | _publishPostAddToViewEvent(context, child); |
222 | 0 | currentChild = child; |
223 | |
} |
224 | 0 | while ((i < children.size()) && |
225 | |
((child = children.get(i)) != currentChild) ); |
226 | 0 | i++; |
227 | |
} |
228 | |
} |
229 | 0 | if (component.getFacetCount() > 0) |
230 | |
{ |
231 | 0 | for (UIComponent child : component.getFacets().values()) |
232 | |
{ |
233 | 0 | _publishPostAddToViewEvent(context, child); |
234 | |
} |
235 | |
} |
236 | 0 | } |
237 | |
|
238 | |
|
239 | |
|
240 | |
|
241 | |
|
242 | |
|
243 | |
|
244 | |
private static void _publishPreRemoveFromViewEvent(FacesContext context, UIComponent component) |
245 | |
{ |
246 | 0 | component.setInView(false); |
247 | 0 | context.getApplication().publishEvent(context, PreRemoveFromViewEvent.class, UIComponent.class, component); |
248 | |
|
249 | 0 | if (component.getChildCount() > 0) |
250 | |
{ |
251 | 0 | for (UIComponent child : component.getChildren()) |
252 | |
{ |
253 | 0 | _publishPreRemoveFromViewEvent(context, child); |
254 | |
} |
255 | |
} |
256 | 0 | if (component.getFacetCount() > 0) |
257 | |
{ |
258 | 0 | for (UIComponent child : component.getFacets().values()) |
259 | |
{ |
260 | 0 | _publishPreRemoveFromViewEvent(context, child); |
261 | |
} |
262 | |
} |
263 | 0 | } |
264 | |
|
265 | |
|
266 | |
|
267 | |
|
268 | |
|
269 | |
|
270 | |
|
271 | |
|
272 | |
public void addClientBehavior(String eventName, ClientBehavior behavior) |
273 | |
{ |
274 | 0 | Collection<String> eventNames = getEventNames(); |
275 | |
|
276 | 0 | if(eventNames == null) |
277 | |
{ |
278 | |
|
279 | |
|
280 | 0 | if(log.isLoggable(Level.SEVERE)) |
281 | |
{ |
282 | 0 | log.severe("attempted to add a behavior to a component which did not properly implement getEventNames. getEventNames must not return null"); |
283 | 0 | return; |
284 | |
} |
285 | |
} |
286 | |
|
287 | 0 | if(eventNames.contains(eventName)) |
288 | |
{ |
289 | 0 | if(_behaviorsMap == null) |
290 | |
{ |
291 | 0 | _behaviorsMap = new HashMap<String,List<ClientBehavior>>(); |
292 | |
} |
293 | |
|
294 | 0 | List<ClientBehavior> behaviorsForEvent = _behaviorsMap.get(eventName); |
295 | 0 | if(behaviorsForEvent == null) |
296 | |
{ |
297 | 0 | behaviorsForEvent = new _DeltaList<ClientBehavior>(new ArrayList<ClientBehavior>()); |
298 | 0 | _behaviorsMap.put(eventName, behaviorsForEvent); |
299 | |
} |
300 | |
|
301 | 0 | behaviorsForEvent.add(behavior); |
302 | 0 | _unmodifiableBehaviorsMap = null; |
303 | |
} |
304 | 0 | } |
305 | |
|
306 | |
|
307 | |
|
308 | |
|
309 | |
|
310 | |
|
311 | |
|
312 | |
|
313 | |
|
314 | |
|
315 | |
|
316 | |
|
317 | |
|
318 | |
|
319 | |
|
320 | |
|
321 | |
|
322 | |
|
323 | |
|
324 | |
@Override |
325 | |
public void broadcast(FacesEvent event) throws AbortProcessingException |
326 | |
{ |
327 | 0 | if (event == null) |
328 | 0 | throw new NullPointerException("event"); |
329 | |
try |
330 | |
{ |
331 | 0 | if (event instanceof BehaviorEvent && event.getComponent() == this) |
332 | |
{ |
333 | 0 | Behavior behavior = ((BehaviorEvent) event).getBehavior(); |
334 | 0 | behavior.broadcast((BehaviorEvent) event); |
335 | |
} |
336 | |
|
337 | 0 | if (_facesListeners == null) |
338 | 0 | return; |
339 | 0 | for (Iterator<FacesListener> it = _facesListeners.iterator(); it.hasNext();) |
340 | |
{ |
341 | 0 | FacesListener facesListener = it.next(); |
342 | 0 | if (event.isAppropriateListener(facesListener)) |
343 | |
{ |
344 | 0 | event.processListener(facesListener); |
345 | |
} |
346 | 0 | } |
347 | |
} |
348 | 0 | catch (Exception ex) |
349 | |
{ |
350 | 0 | if (ex instanceof AbortProcessingException) |
351 | |
{ |
352 | 0 | throw (AbortProcessingException) ex; |
353 | |
} |
354 | 0 | String location = getComponentLocation(this); |
355 | 0 | throw new FacesException("Exception while calling broadcast on component : " |
356 | |
+ getPathToComponent(this) |
357 | |
+ (location != null ? " created from: " + location : ""), ex); |
358 | 0 | } |
359 | 0 | } |
360 | |
|
361 | |
public void clearInitialState() |
362 | |
{ |
363 | 0 | super.clearInitialState(); |
364 | 0 | if (_facesListeners != null) |
365 | |
{ |
366 | 0 | _facesListeners.clearInitialState(); |
367 | |
} |
368 | 0 | if (_behaviorsMap != null) |
369 | |
{ |
370 | 0 | for (Map.Entry<String, List<ClientBehavior> > entry : _behaviorsMap.entrySet()) |
371 | |
{ |
372 | 0 | ((PartialStateHolder) entry.getValue()).clearInitialState(); |
373 | |
} |
374 | |
} |
375 | 0 | if (_systemEventListenerClassMap != null) |
376 | |
{ |
377 | |
for (Map.Entry<Class<? extends SystemEvent>, List<SystemEventListener>> entry : |
378 | 0 | _systemEventListenerClassMap.entrySet()) |
379 | |
{ |
380 | 0 | ((PartialStateHolder) entry.getValue()).clearInitialState(); |
381 | |
} |
382 | |
} |
383 | 0 | } |
384 | |
|
385 | |
|
386 | |
|
387 | |
|
388 | |
|
389 | |
@Override |
390 | |
public void decode(FacesContext context) |
391 | |
{ |
392 | 0 | if (context == null) |
393 | 0 | throw new NullPointerException("context"); |
394 | |
try |
395 | |
{ |
396 | 0 | Renderer renderer = getRenderer(context); |
397 | 0 | if (renderer != null) |
398 | |
{ |
399 | 0 | renderer.decode(context, this); |
400 | |
} |
401 | |
} |
402 | 0 | catch (Exception ex) |
403 | |
{ |
404 | 0 | String location = getComponentLocation(this); |
405 | 0 | throw new FacesException("Exception while decoding component : " |
406 | |
+ getPathToComponent(this) |
407 | |
+ (location != null ? " created from: " + location : ""), ex); |
408 | 0 | } |
409 | 0 | } |
410 | |
|
411 | |
@Override |
412 | |
public void encodeBegin(FacesContext context) throws IOException |
413 | |
{ |
414 | 0 | if (context == null) |
415 | |
{ |
416 | 0 | throw new NullPointerException("context"); |
417 | |
} |
418 | |
|
419 | |
try |
420 | |
{ |
421 | 0 | setCachedFacesContext(context); |
422 | |
|
423 | 0 | pushComponentToEL(context, this); |
424 | |
|
425 | 0 | if (isRendered()) |
426 | |
{ |
427 | |
|
428 | |
|
429 | |
|
430 | |
|
431 | |
|
432 | |
|
433 | |
|
434 | |
|
435 | 0 | context.getApplication().publishEvent(context, PreRenderComponentEvent.class, UIComponent.class, this); |
436 | |
|
437 | 0 | Renderer renderer = getRenderer(context); |
438 | 0 | if (renderer != null) |
439 | |
{ |
440 | |
|
441 | |
|
442 | 0 | renderer.encodeBegin(context, this); |
443 | |
} |
444 | |
} |
445 | |
} |
446 | |
finally |
447 | |
{ |
448 | 0 | setCachedFacesContext(null); |
449 | 0 | } |
450 | 0 | } |
451 | |
|
452 | |
@Override |
453 | |
public void encodeChildren(FacesContext context) throws IOException |
454 | |
{ |
455 | 0 | if (context == null) |
456 | |
{ |
457 | 0 | throw new NullPointerException("context"); |
458 | |
} |
459 | |
|
460 | 0 | boolean isCachedFacesContext = isCachedFacesContext(); |
461 | |
try |
462 | |
{ |
463 | 0 | if (!isCachedFacesContext) |
464 | |
{ |
465 | 0 | setCachedFacesContext(context); |
466 | |
} |
467 | 0 | if (isRendered()) |
468 | |
{ |
469 | |
|
470 | |
|
471 | 0 | Renderer renderer = getRenderer(context); |
472 | 0 | if (renderer == null) |
473 | |
{ |
474 | |
|
475 | |
|
476 | 0 | if (getChildCount() > 0) |
477 | |
{ |
478 | 0 | for (UIComponent child : getChildren()) |
479 | |
{ |
480 | 0 | child.encodeAll(context); |
481 | |
} |
482 | |
} |
483 | |
} |
484 | |
else |
485 | |
{ |
486 | |
|
487 | |
|
488 | 0 | renderer.encodeChildren(context, this); |
489 | |
} |
490 | |
} |
491 | |
} |
492 | |
finally |
493 | |
{ |
494 | 0 | if (!isCachedFacesContext) |
495 | |
{ |
496 | 0 | setCachedFacesContext(null); |
497 | |
} |
498 | |
} |
499 | 0 | } |
500 | |
|
501 | |
@Override |
502 | |
public void encodeEnd(FacesContext context) throws IOException |
503 | |
{ |
504 | |
try |
505 | |
{ |
506 | 0 | if (context == null) |
507 | |
{ |
508 | 0 | throw new NullPointerException("context"); |
509 | |
} |
510 | 0 | setCachedFacesContext(context); |
511 | 0 | if (isRendered()) |
512 | |
{ |
513 | |
|
514 | 0 | Renderer renderer = getRenderer(context); |
515 | 0 | if (renderer != null) |
516 | |
{ |
517 | |
|
518 | |
|
519 | 0 | renderer.encodeEnd(context, this); |
520 | |
} |
521 | |
} |
522 | |
} |
523 | |
finally |
524 | |
{ |
525 | |
|
526 | |
|
527 | 0 | popComponentFromEL(context); |
528 | 0 | setCachedFacesContext(null); |
529 | 0 | } |
530 | 0 | } |
531 | |
|
532 | |
|
533 | |
|
534 | |
|
535 | |
|
536 | |
|
537 | |
|
538 | |
|
539 | |
|
540 | |
|
541 | |
|
542 | |
|
543 | |
|
544 | |
|
545 | |
|
546 | |
|
547 | |
|
548 | |
|
549 | |
|
550 | |
|
551 | |
|
552 | |
|
553 | |
|
554 | |
|
555 | |
@Override |
556 | |
public UIComponent findComponent(String expr) |
557 | |
{ |
558 | 0 | if (expr == null) |
559 | 0 | throw new NullPointerException("expr"); |
560 | 0 | if (expr.length() == 0) |
561 | 0 | return null; |
562 | |
|
563 | 0 | final char separatorChar = UINamingContainer.getSeparatorChar(getFacesContext()); |
564 | |
UIComponent findBase; |
565 | 0 | if (expr.charAt(0) == separatorChar) |
566 | |
{ |
567 | 0 | findBase = _ComponentUtils.getRootComponent(this); |
568 | 0 | expr = expr.substring(1); |
569 | |
} |
570 | |
else |
571 | |
{ |
572 | 0 | if (this instanceof NamingContainer) |
573 | |
{ |
574 | 0 | findBase = this; |
575 | |
} |
576 | |
else |
577 | |
{ |
578 | 0 | findBase = _ComponentUtils.findParentNamingContainer(this, true ); |
579 | |
} |
580 | |
} |
581 | |
|
582 | 0 | int separator = expr.indexOf(separatorChar); |
583 | 0 | if (separator == -1) |
584 | |
{ |
585 | 0 | return _ComponentUtils.findComponent(findBase, expr, separatorChar); |
586 | |
} |
587 | |
|
588 | 0 | String id = expr.substring(0, separator); |
589 | 0 | findBase = _ComponentUtils.findComponent(findBase, id, separatorChar); |
590 | 0 | if (findBase == null) |
591 | |
{ |
592 | 0 | return null; |
593 | |
} |
594 | |
|
595 | 0 | if (!(findBase instanceof NamingContainer)) |
596 | 0 | throw new IllegalArgumentException("Intermediate identifier " + id + " in search expression " + expr |
597 | |
+ " identifies a UIComponent that is not a NamingContainer"); |
598 | |
|
599 | 0 | return findBase.findComponent(expr.substring(separator + 1)); |
600 | |
|
601 | |
} |
602 | |
|
603 | |
|
604 | |
|
605 | |
|
606 | |
|
607 | |
|
608 | |
|
609 | |
|
610 | |
|
611 | |
|
612 | |
|
613 | |
|
614 | |
|
615 | |
|
616 | |
|
617 | |
|
618 | |
|
619 | |
|
620 | |
|
621 | |
|
622 | |
|
623 | |
|
624 | |
|
625 | |
|
626 | |
|
627 | |
|
628 | |
|
629 | |
|
630 | |
|
631 | |
|
632 | |
|
633 | |
|
634 | |
|
635 | |
|
636 | |
|
637 | |
|
638 | |
|
639 | |
|
640 | |
|
641 | |
@Override |
642 | |
public Map<String, Object> getAttributes() |
643 | |
{ |
644 | 0 | if (_attributesMap == null) |
645 | |
{ |
646 | 0 | _attributesMap = new _ComponentAttributesMap(this); |
647 | |
} |
648 | |
|
649 | 0 | return _attributesMap; |
650 | |
} |
651 | |
|
652 | |
|
653 | |
|
654 | |
|
655 | |
|
656 | |
|
657 | |
|
658 | |
@Override |
659 | |
public int getChildCount() |
660 | |
{ |
661 | 0 | return _childrenList == null ? 0 : _childrenList.size(); |
662 | |
} |
663 | |
|
664 | |
|
665 | |
|
666 | |
|
667 | |
|
668 | |
|
669 | |
|
670 | |
|
671 | |
|
672 | |
|
673 | |
|
674 | |
|
675 | |
|
676 | |
@Override |
677 | |
public List<UIComponent> getChildren() |
678 | |
{ |
679 | 0 | if (_childrenList == null) |
680 | |
{ |
681 | 0 | _childrenList = new _ComponentChildrenList(this); |
682 | |
} |
683 | 0 | return _childrenList; |
684 | |
} |
685 | |
|
686 | |
|
687 | |
|
688 | |
|
689 | |
|
690 | |
|
691 | |
|
692 | |
public Map<String,List<ClientBehavior>> getClientBehaviors() |
693 | |
{ |
694 | 0 | if(_behaviorsMap == null) |
695 | |
{ |
696 | 0 | return Collections.emptyMap(); |
697 | |
} |
698 | |
|
699 | 0 | return wrapBehaviorsMap(); |
700 | |
} |
701 | |
|
702 | |
|
703 | |
|
704 | |
|
705 | |
|
706 | |
|
707 | |
|
708 | |
|
709 | |
|
710 | |
|
711 | |
|
712 | |
|
713 | |
|
714 | |
|
715 | |
|
716 | |
|
717 | |
|
718 | |
|
719 | |
@Override |
720 | |
public String getClientId(FacesContext context) |
721 | |
{ |
722 | 0 | if (context == null) |
723 | 0 | throw new NullPointerException("context"); |
724 | |
|
725 | 0 | if (_clientId != null) |
726 | 0 | return _clientId; |
727 | |
|
728 | |
|
729 | 0 | String id = getId(); |
730 | 0 | if (id == null) |
731 | |
{ |
732 | |
|
733 | |
|
734 | |
|
735 | |
|
736 | |
|
737 | |
|
738 | |
|
739 | |
|
740 | 0 | UniqueIdVendor parentUniqueIdVendor = _ComponentUtils.findParentUniqueIdVendor(this); |
741 | 0 | if (parentUniqueIdVendor == null) |
742 | |
{ |
743 | 0 | UIViewRoot viewRoot = context.getViewRoot(); |
744 | 0 | if (viewRoot != null) |
745 | |
{ |
746 | 0 | id = viewRoot.createUniqueId(); |
747 | |
} |
748 | |
else |
749 | |
{ |
750 | |
|
751 | 0 | String location = getComponentLocation(this); |
752 | 0 | throw new FacesException("Cannot create clientId. No id is assigned for component" |
753 | |
+ " to create an id and UIViewRoot is not defined: " |
754 | |
+ getPathToComponent(this) |
755 | |
+ (location != null ? " created from: " + location : "")); |
756 | |
} |
757 | 0 | } |
758 | |
else |
759 | |
{ |
760 | 0 | id = parentUniqueIdVendor.createUniqueId(context, null); |
761 | |
} |
762 | 0 | setId(id); |
763 | |
|
764 | |
|
765 | |
} |
766 | |
|
767 | 0 | UIComponent namingContainer = _ComponentUtils.findParentNamingContainer(this, false); |
768 | 0 | if (namingContainer != null) |
769 | |
{ |
770 | 0 | String containerClientId = namingContainer.getContainerClientId(context); |
771 | 0 | if (containerClientId != null) |
772 | |
{ |
773 | 0 | StringBuilder bld = __getSharedStringBuilder(); |
774 | 0 | _clientId = bld.append(containerClientId).append(UINamingContainer.getSeparatorChar(context)).append(id).toString(); |
775 | 0 | } |
776 | |
else |
777 | |
{ |
778 | 0 | _clientId = id; |
779 | |
} |
780 | 0 | } |
781 | |
else |
782 | |
{ |
783 | 0 | _clientId = id; |
784 | |
} |
785 | |
|
786 | 0 | Renderer renderer = getRenderer(context); |
787 | 0 | if (renderer != null) |
788 | |
{ |
789 | 0 | _clientId = renderer.convertClientId(context, _clientId); |
790 | |
} |
791 | |
|
792 | |
|
793 | |
|
794 | |
|
795 | |
|
796 | |
|
797 | |
|
798 | |
|
799 | |
|
800 | |
|
801 | |
|
802 | |
|
803 | |
|
804 | |
|
805 | 0 | return _clientId; |
806 | |
} |
807 | |
|
808 | |
|
809 | |
|
810 | |
|
811 | |
|
812 | |
|
813 | |
|
814 | |
public String getDefaultEventName() |
815 | |
{ |
816 | |
|
817 | 0 | return null; |
818 | |
} |
819 | |
|
820 | |
|
821 | |
|
822 | |
|
823 | |
|
824 | |
|
825 | |
|
826 | |
public Collection<String> getEventNames() |
827 | |
{ |
828 | |
|
829 | 0 | return null; |
830 | |
} |
831 | |
|
832 | |
@Override |
833 | |
public UIComponent getFacet(String name) |
834 | |
{ |
835 | 0 | return _facetMap == null ? null : _facetMap.get(name); |
836 | |
} |
837 | |
|
838 | |
|
839 | |
|
840 | |
|
841 | |
@Override |
842 | |
public int getFacetCount() |
843 | |
{ |
844 | 0 | return _facetMap == null ? 0 : _facetMap.size(); |
845 | |
} |
846 | |
|
847 | |
@Override |
848 | |
public Map<String, UIComponent> getFacets() |
849 | |
{ |
850 | 0 | if (_facetMap == null) |
851 | |
{ |
852 | 0 | _facetMap = new _ComponentFacetMap<UIComponent>(this); |
853 | |
} |
854 | 0 | return _facetMap; |
855 | |
} |
856 | |
|
857 | |
@Override |
858 | |
public Iterator<UIComponent> getFacetsAndChildren() |
859 | |
{ |
860 | |
|
861 | |
|
862 | |
|
863 | |
|
864 | |
|
865 | 0 | if (getFacetCount() == 0) |
866 | |
{ |
867 | 0 | if (getChildCount() == 0) |
868 | 0 | return _EMPTY_UICOMPONENT_ITERATOR; |
869 | |
|
870 | 0 | return getChildren().iterator(); |
871 | |
} |
872 | |
else |
873 | |
{ |
874 | 0 | if (getChildCount() == 0) |
875 | 0 | return getFacets().values().iterator(); |
876 | |
|
877 | 0 | return new _FacetsAndChildrenIterator(getFacets(), getChildren()); |
878 | |
} |
879 | |
} |
880 | |
|
881 | |
|
882 | |
|
883 | |
|
884 | |
|
885 | |
@JSFProperty(rtexprvalue = true) |
886 | |
public String getId() |
887 | |
{ |
888 | 0 | return _id; |
889 | |
} |
890 | |
|
891 | |
@Override |
892 | |
public UIComponent getParent() |
893 | |
{ |
894 | 0 | return _parent; |
895 | |
} |
896 | |
|
897 | |
@Override |
898 | |
public String getRendererType() |
899 | |
{ |
900 | 0 | return (String) getStateHelper().eval(PropertyKeys.rendererType); |
901 | |
} |
902 | |
|
903 | |
|
904 | |
|
905 | |
|
906 | |
|
907 | |
|
908 | |
|
909 | |
|
910 | |
|
911 | |
|
912 | |
|
913 | |
|
914 | |
@Override |
915 | |
public boolean getRendersChildren() |
916 | |
{ |
917 | 0 | Renderer renderer = getRenderer(getFacesContext()); |
918 | 0 | return renderer != null ? renderer.getRendersChildren() : false; |
919 | |
} |
920 | |
|
921 | |
|
922 | |
|
923 | |
|
924 | |
|
925 | |
|
926 | |
|
927 | |
|
928 | |
|
929 | |
|
930 | |
@Override |
931 | |
public ValueBinding getValueBinding(String name) |
932 | |
{ |
933 | 0 | ValueExpression expression = getValueExpression(name); |
934 | 0 | if (expression != null) |
935 | |
{ |
936 | 0 | if (expression instanceof _ValueBindingToValueExpression) |
937 | |
{ |
938 | 0 | return ((_ValueBindingToValueExpression) expression).getValueBinding(); |
939 | |
} |
940 | 0 | return new _ValueExpressionToValueBinding(expression); |
941 | |
} |
942 | 0 | return null; |
943 | |
} |
944 | |
|
945 | |
public boolean initialStateMarked() |
946 | |
{ |
947 | |
|
948 | |
|
949 | 0 | return super.initialStateMarked(); |
950 | |
} |
951 | |
|
952 | |
|
953 | |
|
954 | |
|
955 | |
@Override |
956 | |
public boolean invokeOnComponent(FacesContext context, String clientId, ContextCallback callback) |
957 | |
throws FacesException |
958 | |
{ |
959 | 0 | if (isCachedFacesContext()) |
960 | |
{ |
961 | 0 | return super.invokeOnComponent(context, clientId, callback); |
962 | |
} |
963 | |
else |
964 | |
{ |
965 | |
try |
966 | |
{ |
967 | 0 | setCachedFacesContext(context); |
968 | 0 | return super.invokeOnComponent(context, clientId, callback); |
969 | |
} |
970 | |
finally |
971 | |
{ |
972 | 0 | setCachedFacesContext(null); |
973 | |
} |
974 | |
} |
975 | |
} |
976 | |
|
977 | |
|
978 | |
|
979 | |
@Override |
980 | |
public boolean visitTree(VisitContext context, VisitCallback callback) |
981 | |
{ |
982 | 0 | if (isCachedFacesContext()) |
983 | |
{ |
984 | 0 | return super.visitTree(context, callback); |
985 | |
} |
986 | |
else |
987 | |
{ |
988 | |
try |
989 | |
{ |
990 | 0 | setCachedFacesContext(context.getFacesContext()); |
991 | 0 | return super.visitTree(context, callback); |
992 | |
} |
993 | |
finally |
994 | |
{ |
995 | 0 | setCachedFacesContext(null); |
996 | |
} |
997 | |
} |
998 | |
} |
999 | |
|
1000 | |
|
1001 | |
|
1002 | |
|
1003 | |
@Override |
1004 | |
@JSFProperty |
1005 | |
public boolean isRendered() |
1006 | |
{ |
1007 | 0 | return (Boolean) getStateHelper().eval(PropertyKeys.rendered, DEFAULT_RENDERED); |
1008 | |
} |
1009 | |
|
1010 | |
@JSFProperty(literalOnly = true, istransient = true, tagExcluded = true) |
1011 | |
public boolean isTransient() |
1012 | |
{ |
1013 | 0 | return _transient; |
1014 | |
} |
1015 | |
|
1016 | |
public void markInitialState() |
1017 | |
{ |
1018 | 0 | super.markInitialState(); |
1019 | 0 | if (_facesListeners != null) |
1020 | |
{ |
1021 | 0 | _facesListeners.markInitialState(); |
1022 | |
} |
1023 | 0 | if (_behaviorsMap != null) |
1024 | |
{ |
1025 | 0 | for (Map.Entry<String, List<ClientBehavior> > entry : _behaviorsMap.entrySet()) |
1026 | |
{ |
1027 | 0 | ((PartialStateHolder) entry.getValue()).markInitialState(); |
1028 | |
} |
1029 | |
} |
1030 | 0 | if (_systemEventListenerClassMap != null) |
1031 | |
{ |
1032 | |
for (Map.Entry<Class<? extends SystemEvent>, List<SystemEventListener>> entry : |
1033 | 0 | _systemEventListenerClassMap.entrySet()) |
1034 | |
{ |
1035 | 0 | ((PartialStateHolder) entry.getValue()).markInitialState(); |
1036 | |
} |
1037 | |
} |
1038 | 0 | } |
1039 | |
|
1040 | |
@Override |
1041 | |
protected void addFacesListener(FacesListener listener) |
1042 | |
{ |
1043 | 0 | if (listener == null) |
1044 | 0 | throw new NullPointerException("listener"); |
1045 | 0 | if (_facesListeners == null) |
1046 | |
{ |
1047 | 0 | _facesListeners = new _DeltaList<FacesListener>(new ArrayList<FacesListener>()); |
1048 | |
} |
1049 | 0 | _facesListeners.add(listener); |
1050 | 0 | } |
1051 | |
|
1052 | |
@Override |
1053 | |
protected FacesContext getFacesContext() |
1054 | |
{ |
1055 | 0 | if (_facesContext == null) |
1056 | |
{ |
1057 | 0 | return FacesContext.getCurrentInstance(); |
1058 | |
} |
1059 | |
else |
1060 | |
{ |
1061 | 0 | return _facesContext; |
1062 | |
} |
1063 | |
} |
1064 | |
|
1065 | |
|
1066 | |
@Override |
1067 | |
protected FacesListener[] getFacesListeners(Class clazz) |
1068 | |
{ |
1069 | 0 | if (clazz == null) |
1070 | |
{ |
1071 | 0 | throw new NullPointerException("Class is null"); |
1072 | |
} |
1073 | 0 | if (!FacesListener.class.isAssignableFrom(clazz)) |
1074 | |
{ |
1075 | 0 | throw new IllegalArgumentException("Class " + clazz.getName() + " must implement " + FacesListener.class); |
1076 | |
} |
1077 | |
|
1078 | 0 | if (_facesListeners == null) |
1079 | |
{ |
1080 | 0 | return (FacesListener[]) Array.newInstance(clazz, 0); |
1081 | |
} |
1082 | 0 | List<FacesListener> lst = null; |
1083 | 0 | for (Iterator<FacesListener> it = _facesListeners.iterator(); it.hasNext();) |
1084 | |
{ |
1085 | 0 | FacesListener facesListener = it.next(); |
1086 | 0 | if (facesListener != null && clazz.isAssignableFrom(facesListener.getClass())) |
1087 | |
{ |
1088 | 0 | if (lst == null) |
1089 | 0 | lst = new ArrayList<FacesListener>(); |
1090 | 0 | lst.add(facesListener); |
1091 | |
} |
1092 | 0 | } |
1093 | 0 | if (lst == null) |
1094 | |
{ |
1095 | 0 | return (FacesListener[]) Array.newInstance(clazz, 0); |
1096 | |
} |
1097 | |
|
1098 | 0 | return lst.toArray((FacesListener[]) Array.newInstance(clazz, lst.size())); |
1099 | |
} |
1100 | |
|
1101 | |
@Override |
1102 | |
protected Renderer getRenderer(FacesContext context) |
1103 | |
{ |
1104 | 0 | if (context == null) |
1105 | 0 | throw new NullPointerException("context"); |
1106 | 0 | String rendererType = getRendererType(); |
1107 | 0 | if (rendererType == null) |
1108 | 0 | return null; |
1109 | |
|
1110 | 0 | RenderKit renderKit = context.getRenderKit(); |
1111 | 0 | Renderer renderer = renderKit.getRenderer(getFamily(), rendererType); |
1112 | 0 | if (renderer == null) |
1113 | |
{ |
1114 | 0 | String location = getComponentLocation(this); |
1115 | 0 | String logStr = "No Renderer found for component " + getPathToComponent(this) |
1116 | |
+ " (component-family=" + getFamily() |
1117 | |
+ ", renderer-type=" + rendererType + ")" |
1118 | |
+ (location != null ? " created from: " + location : ""); |
1119 | |
|
1120 | 0 | getFacesContext().getExternalContext().log(logStr); |
1121 | 0 | log.warning(logStr); |
1122 | |
} |
1123 | 0 | return renderer; |
1124 | |
} |
1125 | |
|
1126 | |
@Override |
1127 | |
protected void removeFacesListener(FacesListener listener) |
1128 | |
{ |
1129 | 0 | if (listener == null) |
1130 | |
{ |
1131 | 0 | throw new NullPointerException("listener is null"); |
1132 | |
} |
1133 | |
|
1134 | 0 | if (_facesListeners != null) |
1135 | |
{ |
1136 | 0 | _facesListeners.remove(listener); |
1137 | |
} |
1138 | 0 | } |
1139 | |
|
1140 | |
@Override |
1141 | |
public void queueEvent(FacesEvent event) |
1142 | |
{ |
1143 | 0 | if (event == null) |
1144 | 0 | throw new NullPointerException("event"); |
1145 | 0 | UIComponent parent = getParent(); |
1146 | 0 | if (parent == null) |
1147 | |
{ |
1148 | 0 | throw new IllegalStateException("component is not a descendant of a UIViewRoot"); |
1149 | |
} |
1150 | 0 | parent.queueEvent(event); |
1151 | 0 | } |
1152 | |
|
1153 | |
@Override |
1154 | |
public void processDecodes(FacesContext context) |
1155 | |
{ |
1156 | |
try |
1157 | |
{ |
1158 | 0 | setCachedFacesContext(context); |
1159 | 0 | if (_isPhaseExecutable(context)) |
1160 | |
{ |
1161 | |
|
1162 | 0 | pushComponentToEL(context, this); |
1163 | |
|
1164 | |
try |
1165 | |
{ |
1166 | |
|
1167 | |
|
1168 | 0 | for (Iterator<UIComponent> it = getFacetsAndChildren(); it.hasNext();) |
1169 | |
{ |
1170 | 0 | it.next().processDecodes(context); |
1171 | |
} |
1172 | |
|
1173 | |
try |
1174 | |
{ |
1175 | |
|
1176 | 0 | decode(context); |
1177 | |
} |
1178 | 0 | catch (RuntimeException e) |
1179 | |
{ |
1180 | |
|
1181 | |
|
1182 | 0 | context.renderResponse(); |
1183 | 0 | throw e; |
1184 | 0 | } |
1185 | |
} |
1186 | |
finally |
1187 | |
{ |
1188 | |
|
1189 | |
|
1190 | |
|
1191 | 0 | popComponentFromEL(context); |
1192 | 0 | } |
1193 | |
} |
1194 | |
} |
1195 | |
finally |
1196 | |
{ |
1197 | 0 | setCachedFacesContext(null); |
1198 | 0 | } |
1199 | 0 | } |
1200 | |
|
1201 | |
@Override |
1202 | |
public void processValidators(FacesContext context) |
1203 | |
{ |
1204 | |
try |
1205 | |
{ |
1206 | 0 | setCachedFacesContext(context); |
1207 | 0 | if (_isPhaseExecutable(context)) |
1208 | |
{ |
1209 | |
|
1210 | 0 | pushComponentToEL(context, this); |
1211 | |
|
1212 | |
try |
1213 | |
{ |
1214 | |
|
1215 | |
|
1216 | 0 | for (Iterator<UIComponent> it = getFacetsAndChildren(); it.hasNext();) |
1217 | |
{ |
1218 | 0 | it.next().processValidators(context); |
1219 | |
} |
1220 | |
} |
1221 | |
finally |
1222 | |
{ |
1223 | 0 | popComponentFromEL(context); |
1224 | 0 | } |
1225 | |
} |
1226 | |
} |
1227 | |
finally |
1228 | |
{ |
1229 | 0 | setCachedFacesContext(null); |
1230 | 0 | } |
1231 | 0 | } |
1232 | |
|
1233 | |
|
1234 | |
|
1235 | |
|
1236 | |
|
1237 | |
|
1238 | |
|
1239 | |
|
1240 | |
|
1241 | |
@Override |
1242 | |
public void processUpdates(FacesContext context) |
1243 | |
{ |
1244 | |
try |
1245 | |
{ |
1246 | 0 | setCachedFacesContext(context); |
1247 | 0 | if (_isPhaseExecutable(context)) |
1248 | |
{ |
1249 | |
|
1250 | 0 | pushComponentToEL(context, this); |
1251 | |
|
1252 | |
try |
1253 | |
{ |
1254 | |
|
1255 | |
|
1256 | 0 | for (Iterator<UIComponent> it = getFacetsAndChildren(); it.hasNext();) |
1257 | |
{ |
1258 | 0 | it.next().processUpdates(context); |
1259 | |
} |
1260 | |
} |
1261 | |
finally |
1262 | |
{ |
1263 | |
|
1264 | |
|
1265 | 0 | popComponentFromEL(context); |
1266 | 0 | } |
1267 | |
} |
1268 | |
} |
1269 | |
finally |
1270 | |
{ |
1271 | 0 | setCachedFacesContext(null); |
1272 | 0 | } |
1273 | 0 | } |
1274 | |
|
1275 | |
@Override |
1276 | |
public Object processSaveState(FacesContext context) |
1277 | |
{ |
1278 | 0 | if (context == null) |
1279 | |
{ |
1280 | 0 | throw new NullPointerException("context"); |
1281 | |
} |
1282 | |
|
1283 | 0 | if (isTransient()) |
1284 | |
{ |
1285 | |
|
1286 | 0 | return null; |
1287 | |
} |
1288 | |
|
1289 | |
|
1290 | 0 | pushComponentToEL(context, this); |
1291 | |
|
1292 | |
Map<String, Object> facetMap; |
1293 | |
|
1294 | |
List<Object> childrenList; |
1295 | |
|
1296 | |
Object savedState; |
1297 | |
try |
1298 | |
{ |
1299 | 0 | facetMap = null; |
1300 | 0 | int facetCount = getFacetCount(); |
1301 | 0 | if (facetCount > 0) |
1302 | |
{ |
1303 | |
|
1304 | |
|
1305 | |
|
1306 | |
|
1307 | |
|
1308 | 0 | for (Map.Entry<String, UIComponent> entry : getFacets().entrySet()) |
1309 | |
{ |
1310 | 0 | UIComponent component = entry.getValue(); |
1311 | 0 | if (!component.isTransient()) |
1312 | |
{ |
1313 | 0 | if (facetMap == null) |
1314 | |
{ |
1315 | 0 | facetMap = new HashMap<String, Object>(facetCount, 1); |
1316 | |
} |
1317 | |
|
1318 | 0 | facetMap.put(entry.getKey(), component.processSaveState(context)); |
1319 | |
|
1320 | |
|
1321 | |
|
1322 | |
|
1323 | |
} |
1324 | 0 | } |
1325 | |
} |
1326 | 0 | childrenList = null; |
1327 | 0 | int childCount = getChildCount(); |
1328 | 0 | if (childCount > 0) |
1329 | |
{ |
1330 | |
|
1331 | |
|
1332 | |
|
1333 | |
|
1334 | |
|
1335 | 0 | for (UIComponent child : getChildren()) |
1336 | |
{ |
1337 | 0 | if (!child.isTransient()) |
1338 | |
{ |
1339 | 0 | if (childrenList == null) |
1340 | |
{ |
1341 | 0 | childrenList = new ArrayList<Object>(childCount); |
1342 | |
} |
1343 | |
|
1344 | 0 | Object childState = child.processSaveState(context); |
1345 | 0 | if (childState != null) |
1346 | |
{ |
1347 | 0 | childrenList.add(childState); |
1348 | |
} |
1349 | |
|
1350 | |
|
1351 | |
|
1352 | 0 | } |
1353 | |
} |
1354 | |
} |
1355 | |
|
1356 | |
|
1357 | 0 | savedState = saveState(context); |
1358 | |
} |
1359 | |
finally |
1360 | |
{ |
1361 | 0 | popComponentFromEL(context); |
1362 | 0 | } |
1363 | |
|
1364 | |
|
1365 | 0 | return new Object[] { savedState, facetMap, childrenList }; |
1366 | |
} |
1367 | |
|
1368 | |
@SuppressWarnings("unchecked") |
1369 | |
@Override |
1370 | |
public void processRestoreState(FacesContext context, Object state) |
1371 | |
{ |
1372 | 0 | if (context == null) |
1373 | |
{ |
1374 | 0 | throw new NullPointerException("context"); |
1375 | |
} |
1376 | |
|
1377 | 0 | Object[] stateValues = (Object[]) state; |
1378 | |
|
1379 | |
try |
1380 | |
{ |
1381 | |
|
1382 | 0 | pushComponentToEL(context, this); |
1383 | |
|
1384 | |
|
1385 | 0 | restoreState(context, stateValues[0]); |
1386 | |
|
1387 | 0 | Map<String, Object> facetMap = (Map<String, Object>) stateValues[1]; |
1388 | 0 | if (facetMap != null && getFacetCount() > 0) |
1389 | |
{ |
1390 | |
|
1391 | |
|
1392 | |
|
1393 | |
|
1394 | |
|
1395 | 0 | for (Map.Entry<String, UIComponent> entry : getFacets().entrySet()) |
1396 | |
{ |
1397 | 0 | Object facetState = facetMap.get(entry.getKey()); |
1398 | 0 | if (facetState != null) |
1399 | |
{ |
1400 | 0 | entry.getValue().processRestoreState(context, facetState); |
1401 | |
|
1402 | |
|
1403 | |
|
1404 | |
|
1405 | |
} |
1406 | |
else |
1407 | |
{ |
1408 | 0 | context.getExternalContext().log("No state found to restore facet " + entry.getKey()); |
1409 | |
} |
1410 | 0 | } |
1411 | |
} |
1412 | 0 | List<Object> childrenList = (List<Object>) stateValues[2]; |
1413 | 0 | if (childrenList != null && getChildCount() > 0) |
1414 | |
{ |
1415 | |
|
1416 | |
|
1417 | |
|
1418 | |
|
1419 | |
|
1420 | 0 | int idx = 0; |
1421 | 0 | for (UIComponent child : getChildren()) |
1422 | |
{ |
1423 | 0 | if (!child.isTransient()) |
1424 | |
{ |
1425 | 0 | Object childState = childrenList.get(idx++); |
1426 | 0 | if (childState != null) |
1427 | |
{ |
1428 | 0 | child.processRestoreState(context, childState); |
1429 | |
|
1430 | |
|
1431 | |
|
1432 | |
|
1433 | |
} |
1434 | |
else |
1435 | |
{ |
1436 | 0 | context.getExternalContext().log("No state found to restore child of component " + getId()); |
1437 | |
} |
1438 | 0 | } |
1439 | |
} |
1440 | |
} |
1441 | |
} |
1442 | |
finally |
1443 | |
{ |
1444 | 0 | popComponentFromEL(context); |
1445 | 0 | } |
1446 | 0 | } |
1447 | |
|
1448 | |
|
1449 | |
|
1450 | |
|
1451 | |
|
1452 | |
|
1453 | |
private String getComponentLocation(UIComponent component) |
1454 | |
{ |
1455 | 0 | Location location = (Location) component.getAttributes() |
1456 | |
.get(UIComponent.VIEW_LOCATION_KEY); |
1457 | 0 | if (location != null) |
1458 | |
{ |
1459 | 0 | return location.toString(); |
1460 | |
} |
1461 | 0 | return null; |
1462 | |
} |
1463 | |
|
1464 | |
private String getPathToComponent(UIComponent component) |
1465 | |
{ |
1466 | 0 | StringBuffer buf = new StringBuffer(); |
1467 | |
|
1468 | 0 | if (component == null) |
1469 | |
{ |
1470 | 0 | buf.append("{Component-Path : "); |
1471 | 0 | buf.append("[null]}"); |
1472 | 0 | return buf.toString(); |
1473 | |
} |
1474 | |
|
1475 | 0 | getPathToComponent(component, buf); |
1476 | |
|
1477 | 0 | buf.insert(0, "{Component-Path : "); |
1478 | 0 | buf.append("}"); |
1479 | |
|
1480 | 0 | return buf.toString(); |
1481 | |
} |
1482 | |
|
1483 | |
private void getPathToComponent(UIComponent component, StringBuffer buf) |
1484 | |
{ |
1485 | 0 | if (component == null) |
1486 | 0 | return; |
1487 | |
|
1488 | 0 | StringBuffer intBuf = new StringBuffer(); |
1489 | |
|
1490 | 0 | intBuf.append("[Class: "); |
1491 | 0 | intBuf.append(component.getClass().getName()); |
1492 | 0 | if (component instanceof UIViewRoot) |
1493 | |
{ |
1494 | 0 | intBuf.append(",ViewId: "); |
1495 | 0 | intBuf.append(((UIViewRoot) component).getViewId()); |
1496 | |
} |
1497 | |
else |
1498 | |
{ |
1499 | 0 | intBuf.append(",Id: "); |
1500 | 0 | intBuf.append(component.getId()); |
1501 | |
} |
1502 | 0 | intBuf.append("]"); |
1503 | |
|
1504 | 0 | buf.insert(0, intBuf.toString()); |
1505 | |
|
1506 | 0 | getPathToComponent(component.getParent(), buf); |
1507 | 0 | } |
1508 | |
|
1509 | |
public void setTransient(boolean transientFlag) |
1510 | |
{ |
1511 | 0 | _transient = transientFlag; |
1512 | 0 | } |
1513 | |
|
1514 | |
|
1515 | |
|
1516 | |
|
1517 | |
|
1518 | |
|
1519 | |
|
1520 | |
|
1521 | |
|
1522 | |
|
1523 | |
|
1524 | |
|
1525 | |
|
1526 | |
|
1527 | |
|
1528 | |
|
1529 | |
|
1530 | |
|
1531 | |
|
1532 | |
public static Object saveAttachedState(FacesContext context, Object attachedObject) |
1533 | |
{ |
1534 | 0 | if (context == null) |
1535 | |
{ |
1536 | 0 | throw new NullPointerException ("context"); |
1537 | |
} |
1538 | |
|
1539 | 0 | if (attachedObject == null) |
1540 | 0 | return null; |
1541 | |
|
1542 | |
|
1543 | 0 | if (attachedObject instanceof StateHolder) |
1544 | |
{ |
1545 | 0 | StateHolder holder = (StateHolder) attachedObject; |
1546 | 0 | if (holder.isTransient()) |
1547 | |
{ |
1548 | 0 | return null; |
1549 | |
} |
1550 | |
|
1551 | 0 | return new _AttachedStateWrapper(attachedObject.getClass(), holder.saveState(context)); |
1552 | |
} |
1553 | 0 | else if (attachedObject instanceof List) |
1554 | |
{ |
1555 | 0 | List<Object> lst = new ArrayList<Object>(((List<?>) attachedObject).size()); |
1556 | 0 | for (Object item : (List<?>) attachedObject) |
1557 | |
{ |
1558 | 0 | if (item != null) |
1559 | |
{ |
1560 | 0 | lst.add(saveAttachedState(context, item)); |
1561 | |
} |
1562 | |
} |
1563 | |
|
1564 | 0 | return new _AttachedListStateWrapper(lst); |
1565 | |
} |
1566 | 0 | else if (attachedObject instanceof Serializable) |
1567 | |
{ |
1568 | 0 | return attachedObject; |
1569 | |
} |
1570 | |
else |
1571 | |
{ |
1572 | 0 | return new _AttachedStateWrapper(attachedObject.getClass(), null); |
1573 | |
} |
1574 | |
} |
1575 | |
|
1576 | |
public static Object restoreAttachedState(FacesContext context, Object stateObj) throws IllegalStateException |
1577 | |
{ |
1578 | 0 | if (context == null) |
1579 | 0 | throw new NullPointerException("context"); |
1580 | 0 | if (stateObj == null) |
1581 | 0 | return null; |
1582 | 0 | if (stateObj instanceof _AttachedListStateWrapper) |
1583 | |
{ |
1584 | 0 | List<Object> lst = ((_AttachedListStateWrapper) stateObj).getWrappedStateList(); |
1585 | 0 | List<Object> restoredList = new ArrayList<Object>(lst.size()); |
1586 | 0 | for (Object item : lst) |
1587 | |
{ |
1588 | 0 | restoredList.add(restoreAttachedState(context, item)); |
1589 | |
} |
1590 | 0 | return restoredList; |
1591 | |
} |
1592 | 0 | else if (stateObj instanceof _AttachedStateWrapper) |
1593 | |
{ |
1594 | 0 | Class<?> clazz = ((_AttachedStateWrapper) stateObj).getClazz(); |
1595 | |
Object restoredObject; |
1596 | |
try |
1597 | |
{ |
1598 | 0 | restoredObject = clazz.newInstance(); |
1599 | |
} |
1600 | 0 | catch (InstantiationException e) |
1601 | |
{ |
1602 | 0 | throw new RuntimeException("Could not restore StateHolder of type " + clazz.getName() |
1603 | |
+ " (missing no-args constructor?)", e); |
1604 | |
} |
1605 | 0 | catch (IllegalAccessException e) |
1606 | |
{ |
1607 | 0 | throw new RuntimeException(e); |
1608 | 0 | } |
1609 | 0 | if (restoredObject instanceof StateHolder) |
1610 | |
{ |
1611 | 0 | _AttachedStateWrapper wrapper = (_AttachedStateWrapper) stateObj; |
1612 | 0 | Object wrappedState = wrapper.getWrappedStateObject(); |
1613 | |
|
1614 | 0 | StateHolder holder = (StateHolder) restoredObject; |
1615 | 0 | holder.restoreState(context, wrappedState); |
1616 | |
} |
1617 | 0 | return restoredObject; |
1618 | |
} |
1619 | |
else |
1620 | |
{ |
1621 | 0 | return stateObj; |
1622 | |
} |
1623 | |
} |
1624 | |
|
1625 | |
|
1626 | |
|
1627 | |
|
1628 | |
|
1629 | |
|
1630 | |
public Object saveState(FacesContext context) |
1631 | |
{ |
1632 | 0 | if (context == null) |
1633 | |
{ |
1634 | 0 | throw new NullPointerException ("context"); |
1635 | |
} |
1636 | |
|
1637 | 0 | if (initialStateMarked()) |
1638 | |
{ |
1639 | |
|
1640 | |
|
1641 | |
|
1642 | 0 | Object facesListenersSaved = saveFacesListenersList(context); |
1643 | 0 | Object behaviorsMapSaved = saveBehaviorsMap(context); |
1644 | 0 | Object systemEventListenerClassMapSaved = saveSystemEventListenerClassMap(context); |
1645 | 0 | Object stateHelperSaved = null; |
1646 | 0 | StateHelper stateHelper = getStateHelper(false); |
1647 | 0 | if (stateHelper != null) |
1648 | |
{ |
1649 | 0 | stateHelperSaved = stateHelper.saveState(context); |
1650 | |
} |
1651 | |
|
1652 | 0 | if (facesListenersSaved == null && stateHelperSaved == null && |
1653 | |
behaviorsMapSaved == null && systemEventListenerClassMapSaved == null) |
1654 | |
{ |
1655 | 0 | return null; |
1656 | |
} |
1657 | |
|
1658 | 0 | return new Object[] {facesListenersSaved, stateHelperSaved, behaviorsMapSaved, systemEventListenerClassMapSaved}; |
1659 | |
} |
1660 | |
else |
1661 | |
{ |
1662 | |
|
1663 | 0 | Object values[] = new Object[6]; |
1664 | 0 | values[0] = saveFacesListenersList(context); |
1665 | 0 | StateHelper stateHelper = getStateHelper(false); |
1666 | 0 | if (stateHelper != null) |
1667 | |
{ |
1668 | 0 | values[1] = stateHelper.saveState(context); |
1669 | |
} |
1670 | 0 | values[2] = saveBehaviorsMap(context); |
1671 | 0 | values[3] = saveSystemEventListenerClassMap(context); |
1672 | 0 | values[4] = _id; |
1673 | 0 | values[5] = _clientId; |
1674 | |
|
1675 | 0 | return values; |
1676 | |
} |
1677 | |
} |
1678 | |
|
1679 | |
|
1680 | |
|
1681 | |
|
1682 | |
|
1683 | |
|
1684 | |
|
1685 | |
|
1686 | |
|
1687 | |
@SuppressWarnings("unchecked") |
1688 | |
public void restoreState(FacesContext context, Object state) |
1689 | |
{ |
1690 | 0 | if (context == null) |
1691 | |
{ |
1692 | 0 | throw new NullPointerException ("context"); |
1693 | |
} |
1694 | |
|
1695 | 0 | if (state == null) |
1696 | |
{ |
1697 | |
|
1698 | |
|
1699 | 0 | if (initialStateMarked()) { |
1700 | 0 | return; |
1701 | |
} |
1702 | |
|
1703 | 0 | throw new NullPointerException ("state"); |
1704 | |
} |
1705 | |
|
1706 | 0 | Object values[] = (Object[]) state; |
1707 | |
|
1708 | 0 | if ( values.length == 6 && initialStateMarked()) |
1709 | |
{ |
1710 | |
|
1711 | |
|
1712 | |
|
1713 | 0 | clearInitialState(); |
1714 | |
} |
1715 | |
|
1716 | 0 | if (values[0] instanceof _AttachedDeltaWrapper) |
1717 | |
{ |
1718 | |
|
1719 | |
|
1720 | |
|
1721 | |
|
1722 | 0 | ((StateHolder)_facesListeners).restoreState(context, |
1723 | |
((_AttachedDeltaWrapper) values[0]).getWrappedStateObject()); |
1724 | |
|
1725 | |
} |
1726 | 0 | else if (values[0] != null || (values.length == 6)) |
1727 | |
{ |
1728 | |
|
1729 | 0 | _facesListeners = (_DeltaList<FacesListener>) |
1730 | |
restoreAttachedState(context,values[0]); |
1731 | |
} |
1732 | |
|
1733 | |
|
1734 | |
|
1735 | |
|
1736 | |
|
1737 | 0 | getStateHelper().restoreState(context, values[1]); |
1738 | |
|
1739 | 0 | if (values.length == 6) |
1740 | |
{ |
1741 | |
|
1742 | 0 | restoreFullBehaviorsMap(context, values[2]); |
1743 | 0 | restoreFullSystemEventListenerClassMap(context, values[3]); |
1744 | |
} |
1745 | |
else |
1746 | |
{ |
1747 | |
|
1748 | 0 | restoreDeltaBehaviorsMap(context, values[2]); |
1749 | 0 | restoreDeltaSystemEventListenerClassMap(context, values[3]); |
1750 | |
} |
1751 | |
|
1752 | 0 | if (values.length == 6) |
1753 | |
{ |
1754 | 0 | _id = (String) values[4]; |
1755 | 0 | _clientId = (String) values[5]; |
1756 | |
} |
1757 | 0 | } |
1758 | |
|
1759 | |
private Object saveFacesListenersList(FacesContext facesContext) |
1760 | |
{ |
1761 | 0 | PartialStateHolder holder = (PartialStateHolder) _facesListeners; |
1762 | 0 | if (initialStateMarked() && _facesListeners != null && holder.initialStateMarked()) |
1763 | |
{ |
1764 | 0 | Object attachedState = holder.saveState(facesContext); |
1765 | 0 | if (attachedState != null) |
1766 | |
{ |
1767 | 0 | return new _AttachedDeltaWrapper(_facesListeners.getClass(), |
1768 | |
attachedState); |
1769 | |
} |
1770 | |
|
1771 | 0 | return null; |
1772 | |
} |
1773 | |
else |
1774 | |
{ |
1775 | 0 | return saveAttachedState(facesContext,_facesListeners); |
1776 | |
} |
1777 | |
} |
1778 | |
|
1779 | |
@SuppressWarnings("unchecked") |
1780 | |
private void restoreFullBehaviorsMap(FacesContext facesContext, Object stateObj) |
1781 | |
{ |
1782 | 0 | if (stateObj != null) |
1783 | |
{ |
1784 | 0 | Map<String, Object> stateMap = (Map<String, Object>) stateObj; |
1785 | 0 | int initCapacity = (stateMap.size() * 4 + 3) / 3; |
1786 | 0 | _behaviorsMap = new HashMap<String, List<ClientBehavior> >(initCapacity); |
1787 | 0 | _unmodifiableBehaviorsMap = null; |
1788 | 0 | for (Map.Entry<String, Object> entry : stateMap.entrySet()) |
1789 | |
{ |
1790 | 0 | _behaviorsMap.put(entry.getKey(), (List<ClientBehavior>) restoreAttachedState(facesContext, entry.getValue())); |
1791 | |
} |
1792 | 0 | } |
1793 | |
else |
1794 | |
{ |
1795 | 0 | _behaviorsMap = null; |
1796 | 0 | _unmodifiableBehaviorsMap = null; |
1797 | |
} |
1798 | 0 | } |
1799 | |
|
1800 | |
@SuppressWarnings("unchecked") |
1801 | |
private void restoreDeltaBehaviorsMap(FacesContext facesContext, Object stateObj) |
1802 | |
{ |
1803 | 0 | if (stateObj != null) |
1804 | |
{ |
1805 | 0 | _unmodifiableBehaviorsMap = null; |
1806 | 0 | Map<String, Object> stateMap = (Map<String, Object>) stateObj; |
1807 | 0 | int initCapacity = (stateMap.size() * 4 + 3) / 3; |
1808 | 0 | if (_behaviorsMap == null) |
1809 | |
{ |
1810 | 0 | _behaviorsMap = new HashMap<String, List<ClientBehavior> >(initCapacity); |
1811 | |
} |
1812 | 0 | for (Map.Entry<String, Object> entry : stateMap.entrySet()) |
1813 | |
{ |
1814 | 0 | Object savedObject = entry.getValue(); |
1815 | 0 | if (savedObject instanceof _AttachedDeltaWrapper) |
1816 | |
{ |
1817 | 0 | StateHolder holderList = (StateHolder) _behaviorsMap.get(entry.getKey()); |
1818 | 0 | holderList.restoreState(facesContext, ((_AttachedDeltaWrapper) savedObject).getWrappedStateObject()); |
1819 | 0 | } |
1820 | |
else |
1821 | |
{ |
1822 | 0 | _behaviorsMap.put(entry.getKey(), (List<ClientBehavior>) restoreAttachedState(facesContext, savedObject)); |
1823 | |
} |
1824 | 0 | } |
1825 | |
} |
1826 | 0 | } |
1827 | |
|
1828 | |
private Object saveBehaviorsMap(FacesContext facesContext) |
1829 | |
{ |
1830 | 0 | if (_behaviorsMap != null) |
1831 | |
{ |
1832 | 0 | if (initialStateMarked()) |
1833 | |
{ |
1834 | 0 | HashMap<String, Object> stateMap = new HashMap<String, Object>(_behaviorsMap.size(), 1); |
1835 | 0 | boolean nullDelta = true; |
1836 | 0 | for (Map.Entry<String, List<ClientBehavior> > entry : _behaviorsMap.entrySet()) |
1837 | |
{ |
1838 | |
|
1839 | |
|
1840 | 0 | PartialStateHolder holder = (PartialStateHolder) entry.getValue(); |
1841 | 0 | if (holder.initialStateMarked()) |
1842 | |
{ |
1843 | 0 | Object attachedState = holder.saveState(facesContext); |
1844 | 0 | if (attachedState != null) |
1845 | |
{ |
1846 | 0 | stateMap.put(entry.getKey(), new _AttachedDeltaWrapper(_behaviorsMap.getClass(), |
1847 | |
attachedState)); |
1848 | 0 | nullDelta = false; |
1849 | |
} |
1850 | 0 | } |
1851 | |
else |
1852 | |
{ |
1853 | 0 | stateMap.put(entry.getKey(), saveAttachedState(facesContext, holder)); |
1854 | 0 | nullDelta = false; |
1855 | |
} |
1856 | 0 | } |
1857 | 0 | if (nullDelta) |
1858 | |
{ |
1859 | 0 | return null; |
1860 | |
} |
1861 | 0 | return stateMap; |
1862 | |
} |
1863 | |
else |
1864 | |
{ |
1865 | |
|
1866 | 0 | HashMap<String, Object> stateMap = |
1867 | |
new HashMap<String, Object>(_behaviorsMap.size(), 1); |
1868 | 0 | for (Map.Entry<String, List<ClientBehavior> > entry : _behaviorsMap.entrySet()) |
1869 | |
{ |
1870 | 0 | stateMap.put(entry.getKey(), saveAttachedState(facesContext, entry.getValue())); |
1871 | |
} |
1872 | 0 | return stateMap; |
1873 | |
} |
1874 | |
} |
1875 | |
else |
1876 | |
{ |
1877 | 0 | return null; |
1878 | |
} |
1879 | |
} |
1880 | |
|
1881 | |
@SuppressWarnings("unchecked") |
1882 | |
private void restoreFullSystemEventListenerClassMap(FacesContext facesContext, Object stateObj) |
1883 | |
{ |
1884 | 0 | if (stateObj != null) |
1885 | |
{ |
1886 | 0 | Map<Class<? extends SystemEvent>, Object> stateMap = (Map<Class<? extends SystemEvent>, Object>) stateObj; |
1887 | 0 | int initCapacity = (stateMap.size() * 4 + 3) / 3; |
1888 | 0 | _systemEventListenerClassMap = new HashMap<Class<? extends SystemEvent>, List<SystemEventListener>>(initCapacity); |
1889 | 0 | for (Map.Entry<Class<? extends SystemEvent>, Object> entry : stateMap.entrySet()) |
1890 | |
{ |
1891 | 0 | _systemEventListenerClassMap.put(entry.getKey(), (List<SystemEventListener>) restoreAttachedState(facesContext, entry.getValue())); |
1892 | |
} |
1893 | 0 | } |
1894 | |
else |
1895 | |
{ |
1896 | 0 | _systemEventListenerClassMap = null; |
1897 | |
} |
1898 | 0 | } |
1899 | |
|
1900 | |
@SuppressWarnings("unchecked") |
1901 | |
private void restoreDeltaSystemEventListenerClassMap(FacesContext facesContext, Object stateObj) |
1902 | |
{ |
1903 | 0 | if (stateObj != null) |
1904 | |
{ |
1905 | 0 | Map<Class<? extends SystemEvent>, Object> stateMap = (Map<Class<? extends SystemEvent>, Object>) stateObj; |
1906 | 0 | int initCapacity = (stateMap.size() * 4 + 3) / 3; |
1907 | 0 | if (_systemEventListenerClassMap == null) |
1908 | |
{ |
1909 | 0 | _systemEventListenerClassMap = new HashMap<Class<? extends SystemEvent>, List<SystemEventListener>>(initCapacity); |
1910 | |
} |
1911 | 0 | for (Map.Entry<Class<? extends SystemEvent>, Object> entry : stateMap.entrySet()) |
1912 | |
{ |
1913 | 0 | Object savedObject = entry.getValue(); |
1914 | 0 | if (savedObject instanceof _AttachedDeltaWrapper) |
1915 | |
{ |
1916 | 0 | StateHolder holderList = (StateHolder) _systemEventListenerClassMap.get(entry.getKey()); |
1917 | 0 | holderList.restoreState(facesContext, ((_AttachedDeltaWrapper) savedObject).getWrappedStateObject()); |
1918 | 0 | } |
1919 | |
else |
1920 | |
{ |
1921 | 0 | _systemEventListenerClassMap.put(entry.getKey(), (List<SystemEventListener>) restoreAttachedState(facesContext, savedObject)); |
1922 | |
} |
1923 | 0 | } |
1924 | |
} |
1925 | 0 | } |
1926 | |
|
1927 | |
private Object saveSystemEventListenerClassMap(FacesContext facesContext) |
1928 | |
{ |
1929 | 0 | if (_systemEventListenerClassMap != null) |
1930 | |
{ |
1931 | 0 | if (initialStateMarked()) |
1932 | |
{ |
1933 | 0 | HashMap<Class<? extends SystemEvent>, Object> stateMap = new HashMap<Class<? extends SystemEvent>, Object>(_systemEventListenerClassMap.size(), 1); |
1934 | 0 | boolean nullDelta = true; |
1935 | 0 | for (Map.Entry<Class<? extends SystemEvent>, List<SystemEventListener> > entry : _systemEventListenerClassMap.entrySet()) |
1936 | |
{ |
1937 | |
|
1938 | |
|
1939 | 0 | PartialStateHolder holder = (PartialStateHolder) entry.getValue(); |
1940 | 0 | if (holder.initialStateMarked()) |
1941 | |
{ |
1942 | 0 | Object attachedState = holder.saveState(facesContext); |
1943 | 0 | if (attachedState != null) |
1944 | |
{ |
1945 | 0 | stateMap.put(entry.getKey(), new _AttachedDeltaWrapper(_systemEventListenerClassMap.getClass(), |
1946 | |
attachedState)); |
1947 | 0 | nullDelta = false; |
1948 | |
} |
1949 | 0 | } |
1950 | |
else |
1951 | |
{ |
1952 | 0 | stateMap.put(entry.getKey(), saveAttachedState(facesContext, holder)); |
1953 | 0 | nullDelta = false; |
1954 | |
} |
1955 | 0 | } |
1956 | 0 | if (nullDelta) |
1957 | |
{ |
1958 | 0 | return null; |
1959 | |
} |
1960 | 0 | return stateMap; |
1961 | |
} |
1962 | |
else |
1963 | |
{ |
1964 | |
|
1965 | 0 | HashMap<Class<? extends SystemEvent>, Object> stateMap = |
1966 | |
new HashMap<Class<? extends SystemEvent>, Object>(_systemEventListenerClassMap.size(), 1); |
1967 | 0 | for (Map.Entry<Class<? extends SystemEvent>, List<SystemEventListener> > entry : _systemEventListenerClassMap.entrySet()) |
1968 | |
{ |
1969 | 0 | stateMap.put(entry.getKey(), saveAttachedState(facesContext, entry.getValue())); |
1970 | |
} |
1971 | 0 | return stateMap; |
1972 | |
} |
1973 | |
} |
1974 | |
else |
1975 | |
{ |
1976 | 0 | return null; |
1977 | |
} |
1978 | |
} |
1979 | |
|
1980 | |
|
1981 | |
|
1982 | |
|
1983 | |
|
1984 | |
|
1985 | |
|
1986 | |
|
1987 | |
|
1988 | |
|
1989 | |
|
1990 | |
|
1991 | |
|
1992 | |
|
1993 | |
|
1994 | |
|
1995 | |
|
1996 | |
|
1997 | |
|
1998 | |
|
1999 | |
|
2000 | |
|
2001 | |
|
2002 | |
|
2003 | |
|
2004 | |
|
2005 | |
|
2006 | |
|
2007 | |
|
2008 | |
|
2009 | |
|
2010 | |
|
2011 | |
|
2012 | |
|
2013 | |
|
2014 | |
|
2015 | |
|
2016 | |
|
2017 | |
|
2018 | |
|
2019 | |
|
2020 | |
private void isIdValid(String string) |
2021 | |
{ |
2022 | |
|
2023 | |
|
2024 | 0 | if (string == null) |
2025 | 0 | return; |
2026 | |
|
2027 | |
|
2028 | |
|
2029 | 0 | if (string.length() == 0) |
2030 | |
{ |
2031 | 0 | throw new IllegalArgumentException("component identifier must not be a zero-length String"); |
2032 | |
} |
2033 | |
|
2034 | |
|
2035 | 0 | if (string.equals(_id)) |
2036 | |
{ |
2037 | 0 | return; |
2038 | |
} |
2039 | |
|
2040 | |
|
2041 | 0 | if (!Character.isLetter(string.charAt(0)) && string.charAt(0) != '_') |
2042 | |
{ |
2043 | 0 | throw new IllegalArgumentException( |
2044 | |
"component identifier's first character must be a letter or an underscore ('_')! But it is \"" |
2045 | |
+ string.charAt(0) + "\""); |
2046 | |
} |
2047 | 0 | for (int i = 1; i < string.length(); i++) |
2048 | |
{ |
2049 | 0 | char c = string.charAt(i); |
2050 | |
|
2051 | 0 | if (!Character.isLetterOrDigit(c) && c != '-' && c != '_') |
2052 | |
{ |
2053 | 0 | throw new IllegalArgumentException( |
2054 | |
"Subsequent characters of component identifier must be a letter, a digit, an underscore ('_'), or a dash ('-')! But component identifier contains \"" |
2055 | |
+ c + "\""); |
2056 | |
} |
2057 | |
} |
2058 | 0 | } |
2059 | |
|
2060 | |
private boolean _isPhaseExecutable(FacesContext context) |
2061 | |
{ |
2062 | 0 | if (context == null) |
2063 | |
{ |
2064 | 0 | throw new NullPointerException("context"); |
2065 | |
} |
2066 | |
|
2067 | |
|
2068 | 0 | return isRendered(); |
2069 | |
} |
2070 | |
|
2071 | |
boolean isCachedFacesContext() |
2072 | |
{ |
2073 | 0 | return _facesContext != null; |
2074 | |
} |
2075 | |
|
2076 | |
void setCachedFacesContext(FacesContext facesContext) |
2077 | |
{ |
2078 | 0 | _facesContext = facesContext; |
2079 | 0 | } |
2080 | |
|
2081 | |
<T> T getExpressionValue(String attribute, T explizitValue, T defaultValueIfExpressionNull) |
2082 | |
{ |
2083 | 0 | return _ComponentUtils.getExpressionValue(this, attribute, explizitValue, defaultValueIfExpressionNull); |
2084 | |
} |
2085 | |
|
2086 | |
|
2087 | |
|
2088 | |
|
2089 | |
|
2090 | |
|
2091 | |
|
2092 | |
|
2093 | |
|
2094 | |
|
2095 | |
|
2096 | |
|
2097 | |
|
2098 | |
|
2099 | |
|
2100 | |
|
2101 | |
|
2102 | |
|
2103 | |
|
2104 | |
|
2105 | |
|
2106 | |
|
2107 | |
|
2108 | |
|
2109 | |
|
2110 | |
|
2111 | |
|
2112 | |
|
2113 | |
|
2114 | |
|
2115 | |
|
2116 | |
|
2117 | |
|
2118 | |
|
2119 | |
static StringBuilder __getSharedStringBuilder() |
2120 | |
{ |
2121 | 0 | StringBuilder sb = _STRING_BUILDER.get(); |
2122 | |
|
2123 | 0 | if (sb == null) |
2124 | |
{ |
2125 | 0 | sb = new StringBuilder(); |
2126 | 0 | _STRING_BUILDER.set(sb); |
2127 | |
} |
2128 | |
|
2129 | |
|
2130 | 0 | sb.setLength(0); |
2131 | |
|
2132 | 0 | return sb; |
2133 | |
} |
2134 | |
|
2135 | |
|
2136 | |
|
2137 | 0 | private static final Boolean DEFAULT_RENDERED = Boolean.TRUE; |
2138 | |
|
2139 | |
@Override |
2140 | |
public void setRendered(boolean rendered) |
2141 | |
{ |
2142 | 0 | getStateHelper().put(PropertyKeys.rendered, rendered ); |
2143 | 0 | } |
2144 | |
|
2145 | |
@Override |
2146 | |
public void setRendererType(String rendererType) |
2147 | |
{ |
2148 | 0 | getStateHelper().put(PropertyKeys.rendererType, rendererType ); |
2149 | 0 | } |
2150 | |
|
2151 | |
|
2152 | |
|
2153 | |
private Map<String, List<ClientBehavior>> wrapBehaviorsMap() |
2154 | |
{ |
2155 | 0 | if (_unmodifiableBehaviorsMap == null) |
2156 | |
{ |
2157 | 0 | _unmodifiableBehaviorsMap = Collections.unmodifiableMap(_behaviorsMap); |
2158 | |
} |
2159 | 0 | return _unmodifiableBehaviorsMap; |
2160 | |
} |
2161 | |
} |