Ignoring comments in xhtml jsf pages

Last day I had a problem with some code randomly executed in a java bean. After nearly a hour searching for a solution I found some old commented code inside an XHTML jsf page. As you may know, commented XHTML are still executed by jsf.

Well, googling a little, I found this great article: JSF2 XHTML facelets comments appearing in output.

Simply put, if you put the following param in the web.xml of your app, the comment will be ignored:

<context-param>
    <param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
    <param-value>true</param-value>
</context-param>

This could save you a lot of headache.

Tags: