Seam’isms: Comments in JSF/Facelets

I’m not sure why this isn’t a default but c’est la vie, and this is certainly something that has irked me from time to time, so I was quite pleased when I stumbled upon this in the seam forum  which is the little bit of magic to ignore comments in facelets/JSF.

Add the following to your web.xml file:

    <context-param>
        <param-name>facelets.SKIP_COMMENTS</param-name>
        <param-value>true</param-value>
    </context-param>

8 Comments

  1. Jean Michel Baldessar says:

    Is there any alternative solution to this? I don’t want to kill all the comments… =(

  2. techdetails says:

    Not that I know of, I think it is all or nothing. I’m just getting back into seam after working on other non-java projects, if I find a solution I’ll post an update.

  3. Adam Buckley says:

    Yup, totally bizarre why this isn’t turned on by default.

    It only really bothered me when I discovered that a <!– –> comment tag would actually be considerd as a row in a h:panelGrid.

  4. Matthias Hryniszak says:

    I totaly agree! This should be the default setting. It’s so confusing that one might spend a lot of time figuring out whatta hell is going on. Especially when the exception message makes no sense at all. Let me give you an example:

    Suppose you have a composition with 2 or more repeated content that you want to externalize iinto separate file that in turn will be included using ui:include with some parameters. In addition to that you’ll have in the externalized block some usage of rich:suggestionbox (or anything else that expects a method instead of property). Once the code is copied to an external file and the old code is commented out you’ll end up with a message that the object does not have a property named as the method you call. This is really really confusing.

    Best regards,

    Matthias.

  5. Ken T says:

    Just a note.  I actually had to disable this from its default setting under NetBeans of true.  The reason was that I needed to include the Google AdSense script in the code and it is contained within comments in XHTML.  So if you have the ignore comments set, the comments completely disappear from the rendered content, meaning the script disappears.  So in order to get the script back you have to make sure you aren’t completely ignoring coments.

    The default setting makes more sense to me now.

  6. Sascha says:

    Thank you for posting this! I’ve been having problems because of this on and off.

  7. John Dondapati says:

    Thank you so much. You saved me a boat load of work. I was about to go remove comments from each facelet and saw your post.

  8. Ben says:

    Great tip! Just the answer I was looking for.
    Thanks for posting this!

Leave a Reply