{
String id = context.getViewRoot().getRenderKitId();
throw new IllegalStateException("No render kit was available for id \"" + id + "\"");
}
ServletResponse response = (ServletResponse) extContext.getResponse();
// set the buffer for content
if (this.bufferSize != -1)
{
response.setBufferSize(this.bufferSize);
}
// get our content type
String contentType = (String) extContext.getRequestMap().get("facelets.ContentType");
// get the encoding
String encoding = (String) extContext.getRequestMap().get("facelets.Encoding");
ResponseWriter writer;
// append */* to the contentType so createResponseWriter will succeed no matter
// the requested contentType.
if (contentType != null && !contentType.equals("*/*"))
{
contentType += ",*/*";
}
// Create a dummy ResponseWriter with a bogus writer,
// so we can figure out what content type the ReponseWriter
// is really going to ask for
try
{
writer = renderKit.createResponseWriter(NullWriter.INSTANCE, contentType, encoding);
}
catch (IllegalArgumentException e)
{
// Added because of an RI bug prior to 1.2_05-b3. Might as well leave it in case other
// impls have the same problem. https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=613
log.fine("The impl didn't correctly handled '*/*' in the content type list. Trying '*/*' directly.");
writer = renderKit.createResponseWriter(NullWriter.INSTANCE, "*/*", encoding);
}
// Override the JSF provided content type if necessary
contentType = getResponseContentType(context, writer.getContentType());
encoding = getResponseEncoding(context, writer.getCharacterEncoding());
// apply them to the response
response.setContentType(contentType + "; charset=" + encoding);
// removed 2005.8.23 to comply with J2EE 1.3
// response.setCharacterEncoding(encoding);
// Now, clone with the real writer
writer = writer.cloneWithWriter(response.getWriter());
return writer;
}