28

I would like to remove all HTML comments from my facelets before delivering to end users. Does any standard approach exist?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
yegor256
  • 102,010
  • 123
  • 446
  • 597

1 Answers1

50

There are actually two ways:

  1. To remove ALL comments, add this to web.xml:

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

    or when you're still on JSF 1.2 which doesn't use Facelets as default view technology yet:

    <context-param>
        <param-name>facelets.SKIP_COMMENTS</param-name>
        <param-value>true</param-value>
    </context-param>
    
  2. To remove specific comments only, use <ui:remove>.

    <ui:remove><!-- This is a HTML comment. --></ui:remove>
    
Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • 5
    Didn't know that, and i've been working with JSF/Facelets for 1 year. – f1sh Aug 02 '10 at 15:26
  • @Koray: By reading docs (context param is mentioned in page 11-3 of [JSF 2 spec](http://download.oracle.com/otn-pub/jcp/jsf-2.0-fr-full-oth-JSpec/jsf-2_0-fr-spec.pdf)). – BalusC Jul 22 '16 at 18:54
  • @BalusC This is the draft, isn 't it? Is there no final version? – Koray Tugay Jul 22 '16 at 18:55
  • @Koray: no draft, "fr" is final, see also http://download.oracle.com/otndocs/jcp/jsf-2.0-fr-full-oth-JSpec – BalusC Jul 22 '16 at 18:57