1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package org.apache.myfaces.view.facelets.tag.jsf.html; |
20 | |
|
21 | |
import java.util.Iterator; |
22 | |
|
23 | |
import javax.faces.component.UIComponent; |
24 | |
import javax.faces.component.UIViewRoot; |
25 | |
import javax.faces.view.facelets.ComponentConfig; |
26 | |
import javax.faces.view.facelets.FaceletContext; |
27 | |
|
28 | |
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFFaceletTag; |
29 | |
import org.apache.myfaces.view.facelets.FaceletCompositionContext; |
30 | |
import org.apache.myfaces.view.facelets.el.CompositeComponentELUtils; |
31 | |
import org.apache.myfaces.view.facelets.tag.jsf.ComponentSupport; |
32 | |
import org.apache.myfaces.view.facelets.tag.jsf.RelocatableResourceHandler; |
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
@JSFFaceletTag( |
41 | |
name = "h:outputScript", |
42 | |
componentClass = "org.apache.myfaces.view.facelets.tag.jsf.html._HtmlOutputScript") |
43 | |
public class HtmlOutputScriptHandler extends HtmlComponentHandler implements RelocatableResourceHandler |
44 | |
{ |
45 | |
|
46 | |
public HtmlOutputScriptHandler(ComponentConfig config) |
47 | |
{ |
48 | 0 | super(config); |
49 | 0 | } |
50 | |
|
51 | |
public UIComponent findChildByTagId(FaceletContext ctx, UIComponent parent, |
52 | |
String id) |
53 | |
{ |
54 | |
|
55 | 0 | UIComponent c = ComponentSupport.findChildByTagId(parent, id); |
56 | 0 | if (c == null) |
57 | |
{ |
58 | 0 | UIViewRoot root = ComponentSupport.getViewRoot(ctx, parent); |
59 | |
|
60 | 0 | if (root.getFacetCount() > 0) |
61 | |
{ |
62 | 0 | Iterator<UIComponent> itr = root.getFacets().values().iterator(); |
63 | 0 | while (itr.hasNext() && c == null) |
64 | |
{ |
65 | 0 | UIComponent facet = itr.next(); |
66 | 0 | c = ComponentSupport.findChildByTagId(facet, id); |
67 | 0 | } |
68 | |
} |
69 | 0 | return c; |
70 | |
} |
71 | |
else |
72 | |
{ |
73 | 0 | return c; |
74 | |
} |
75 | |
} |
76 | |
|
77 | |
|
78 | |
@Override |
79 | |
public void onComponentCreated(FaceletContext ctx, UIComponent c, |
80 | |
UIComponent parent) |
81 | |
{ |
82 | 0 | UIComponent parentCompositeComponent |
83 | |
= FaceletCompositionContext.getCurrentInstance(ctx).getCompositeComponentFromStack(); |
84 | 0 | if (parentCompositeComponent != null) |
85 | |
{ |
86 | 0 | c.getAttributes().put(CompositeComponentELUtils.LOCATION_KEY, |
87 | |
parentCompositeComponent.getAttributes().get(CompositeComponentELUtils.LOCATION_KEY)); |
88 | |
} |
89 | 0 | } |
90 | |
} |