Monday, 22 June 2009

JSF - ensuring your [xhtml] pages load with a text/html contentType

We were having a problem with Safari and Chrome rendering our JSF pages; all the content was available, but for some reason they refused to load any of the external links to stylesheets, javascript etc. They also refused to render any markup; in fact, all they would show was all the page "content" in the default text.

Further investigation (using fiddler) made it apparent that the pages were being served with the "application/xhtml+xml" when our page templates all had an html 4.01 strict doctype. This caused the WebKit browsers to ignore any links to external assets while Firefox and IE seemed to render the page as expected.

We discovered that creating templates that looked like (where the contentType is specified inside the f:view tag as early as possible) seemed to solve the issue:

No comments:

Blog Archive