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