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.struts.faces.renderer;
23
24
25 import java.io.IOException;
26
27 import javax.faces.component.UIComponent;
28 import javax.faces.context.FacesContext;
29 import javax.faces.context.ResponseWriter;
30
31 import org.apache.commons.logging.Log;
32 import org.apache.commons.logging.LogFactory;
33
34
35 /**
36 * <p><code>Renderer</code> implementation for the <code>stylesheet</code> tag
37 * from the <em>Struts-Faces Integration Library</em>.</p>
38 *
39 * @version $Rev: 471754 $ $Date: 2006-11-06 08:55:09 -0600 (Mon, 06 Nov 2006) $
40 */
41
42 public class StylesheetRenderer extends AbstractRenderer {
43
44
45
46
47
48 /**
49 * <p>The <code>Log</code> instance for this class.</p>
50 */
51 private static Log log = LogFactory.getLog(StylesheetRenderer.class);
52
53
54
55
56
57 /**
58 * <p>Render a relative HTML <code><link></code> element for a
59 * <code>text/css</code> stylesheet at the specified context-relative
60 * path.</p>
61 *
62 * @param context FacesContext for the request we are processing
63 * @param component UIComponent to be rendered
64 *
65 * @exception IOException if an input/output error occurs while rendering
66 * @exception NullPointerException if <code>context</code>
67 * or <code>component</code> is <code>null</code>
68 */
69 public void encodeEnd(FacesContext context, UIComponent component)
70 throws IOException {
71
72 if ((context == null) || (component == null)) {
73 throw new NullPointerException();
74 }
75
76 ResponseWriter writer = context.getResponseWriter();
77 writer.startElement("link", component);
78 writer.writeAttribute("rel", "stylesheet", null);
79 writer.writeAttribute("type", "text/css", null);
80 writer.writeURIAttribute
81 ("href",
82 context.getExternalContext().getRequestContextPath() +
83 (String) component.getAttributes().get("path"), "path");
84 writer.endElement("link");
85 writer.writeText("\n", null);
86
87 }
88
89
90
91
92
93
94 }