1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.myfaces.custom.document;
20
21 import java.io.IOException;
22
23 import javax.faces.component.UIComponent;
24 import javax.faces.component.UIViewRoot;
25 import javax.faces.context.FacesContext;
26
27 import org.apache.myfaces.component.html.util.StreamingAddResource;
28 import org.apache.myfaces.renderkit.html.util.AddResource;
29 import org.apache.myfaces.renderkit.html.util.AddResourceFactory;
30 import org.apache.myfaces.tomahawk.util.TomahawkResourceUtils;
31
32
33
34
35
36
37
38
39
40
41
42
43
44 public class DocumentHeadRenderer extends AbstractDocumentRenderer
45 {
46 public static final String RENDERER_TYPE = "org.apache.myfaces.DocumentHead";
47
48 protected String getHtmlTag()
49 {
50 return "head";
51 }
52
53 protected Class getDocumentClass()
54 {
55 return DocumentHead.class;
56 }
57
58 protected void writeBeforeEnd(FacesContext facesContext) throws IOException
59 {
60 super.writeBeforeEnd(facesContext);
61
62 AddResource addResource = AddResourceFactory.getInstance(facesContext);
63 if (addResource instanceof StreamingAddResource)
64 {
65 ((StreamingAddResource) addResource).addStyleLoaderHere(facesContext, DocumentHead.class);
66 }
67
68 UIViewRoot root = facesContext.getViewRoot();
69 for (UIComponent child : root.getComponentResources(facesContext,
70 TomahawkResourceUtils.HEAD_LOCATION))
71 {
72 child.encodeAll(facesContext);
73 }
74 }
75 }