Showing posts with label google chrome. Show all posts
Showing posts with label google chrome. Show all posts

Sunday, February 28, 2010

Fixing Facelets/XHTML corrupted page issues in Google Chrome

I had a problem for quite some time on a web site being shown corrupted in Google Chrome. On the original HTML page everything was working great. On the resulted JSF/Seam/Facelets produced page, things were looking corrupted. The problem appeared only on Google Chrome. In other web browsers things look good. When I made a diff on the original working page and the page generated by JSF/Seam/Facelets, there was no difference. But still, page was corrupted on Google Chrome. After some investigation I noticed that Google Chrome was showing the page corrupted, simply because the generated page was not setting content type of: text/html. Google Chrome, unlike the other browsers, was probably sensitive to this issue. The solution to this problem is very simple. Just add to your JSF view tag the property: contentType. If your IDE (for example, IntelliJ) marks the contentType as unrecognized, ignore it. It runs ok. Here is an example of how the contentType is used:
<f:view contentType="text/html" />
Note, that you don’t have to wrap the view tag on all of your page, if you are using Facelets (the view tag is not mandatory in Facelets), so just putting the view tag is enough (like in the example).