public void writeString(String contextPath, Writer writer, String contentType,
String characterEncoding) throws IOException
{
HtmlResponseWriterImpl responseWriter = new HtmlResponseWriterImpl(
writer,contentType,characterEncoding);
responseWriter.writeText("\n",null);
switch (type) {
case TYPE_JS:
responseWriter.startElement(HTML.SCRIPT_ELEM,null);
if(baseDirectory != null)
{
responseWriter.writeAttribute(HTML.SRC_ATTR,
getResourceBasePath(baseDirectory)+resourceFileName,
null);
}
else
{
responseWriter.writeAttribute(HTML.SRC_ATTR,
getResourceMappedPath(componentName, resourceFileName, contextPath),null);
}
if(deferJS)
responseWriter.writeAttribute("defer","true",null);
responseWriter.writeAttribute(HTML.SCRIPT_TYPE_ATTR,HTML.SCRIPT_TYPE_TEXT_JAVASCRIPT,null);
responseWriter.endElement(HTML.SCRIPT_ELEM);
break;
case TYPE_CSS:
responseWriter.startElement("link",null);
responseWriter.writeAttribute("rel","stylesheet",null);
if(baseDirectory != null )
{
responseWriter.writeAttribute(
HTML.HREF_ATTR,
baseDirectory+(baseDirectory.endsWith("/")?"":"/")+resourceFileName,
null);
}
else
{
responseWriter.writeAttribute(HTML.HREF_ATTR,
getResourceMappedPath(componentName, resourceFileName, contextPath),null);
}
responseWriter.writeAttribute(HTML.TYPE_ATTR,"text/css",null);
responseWriter.endElement("link");
break;
case TYPE_CSS_INLINE:
responseWriter.startElement(HTML.STYLE_ELEM,null);
responseWriter.writeAttribute("rel","stylesheet",null);
responseWriter.writeAttribute(HTML.TYPE_ATTR,"text/css",null);
responseWriter.writeText(inlineText,null);
responseWriter.endElement(HTML.STYLE_ELEM);
break;
case TYPE_JS_INLINE:
responseWriter.startElement(HTML.SCRIPT_ELEM,null);
responseWriter.writeAttribute(HTML.SCRIPT_TYPE_ATTR,HTML.SCRIPT_TYPE_TEXT_JAVASCRIPT,null);
responseWriter.writeText(inlineText,null);
responseWriter.endElement(HTML.SCRIPT_ELEM);
break;
default:
log.warn("Unknown type:"+type);
}
}