public ResponseWriter createResponseWriter(
Writer writer, String contentTypeList, String characterEncoding) {
String contentType;
FacesContext facesContext = FacesContext.getCurrentInstance();
if (AjaxUtils.isAjaxRequest(facesContext)) {
return new JsonResponseWriter(writer, "application/json", characterEncoding);
}
if (contentTypeList == null) {
contentType = "text/html";
} else if (contentTypeList.indexOf("text/html") > -1) {
contentType = "text/html";
LOG.warn("patching content type from " + contentTypeList + " to " + contentType + "'");
} else if (contentTypeList.indexOf("text/fo") > -1) {
contentType = "text/fo";
LOG.warn("patching content type from " + contentTypeList + " to " + contentType + "'");
} else if (contentTypeList.indexOf("application/json") > -1) {
return new JsonResponseWriter(writer, "application/json", characterEncoding);
} else {
contentType = "text/html";
LOG.warn("Content-Type '" + contentTypeList + "' not supported! Using text/html");
}