1 16 package org.apache.myfaces.custom.stylesheet; 17 18 import java.io.IOException ; 19 20 import javax.faces.component.UIComponent; 21 import javax.faces.context.FacesContext; 22 import javax.faces.context.ResponseWriter; 23 24 import org.apache.myfaces.renderkit.html.HtmlRenderer; 25 26 import org.apache.commons.logging.Log; 27 import org.apache.commons.logging.LogFactory; 28 29 40 41 public class StylesheetRenderer extends HtmlRenderer { 42 43 private static final Log log = LogFactory.getLog(StylesheetRenderer.class); 44 45 public void encodeEnd(FacesContext context, UIComponent component) 46 throws IOException { 47 48 if ((context == null) || (component == null)) { 49 throw new NullPointerException (); 50 } 51 Stylesheet stylesheet = (Stylesheet) component; 52 53 ResponseWriter writer = context.getResponseWriter(); 54 writer.startElement("link", component); 55 writer.writeAttribute("rel", "stylesheet", null); 56 writer.writeAttribute("type", "text/css", null); 57 writer.writeURIAttribute 58 ("href", 59 context.getExternalContext().getRequestContextPath()+stylesheet.getPath(), 60 "path"); 61 writer.endElement("link"); 62 } 63 } | Popular Tags |