Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invisible comments in jsf 2.0? [duplicate]

Tags:

is it possible to embed comments in my .xhtml-files that are only displayed in the source and not the rendered result? I want to include author, date,... in the files but they should not be visible to the enduser in the generated output. If I use the standard comment-tags <!-- --> the browser displays them.

like image 789
Tim Avatar asked Aug 17 '10 08:08

Tim


2 Answers

Add the following into your web.xml:

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

This way Facelets will skip the comments while parsing the view xhtml template.

like image 147
Petar Minchev Avatar answered Oct 02 '22 17:10

Petar Minchev


Invisible comments in JSF is a drawback, specially for beginers. I agree with answer of Mr Minchev. Anyway, I provide an alternative way to comment content in JSF consisting of using ui:remove

<ui:remove> This is a comment </ui:remove>

The UI Remove tag is used to specify tags or blocks of content that should be removed from your page by the Facelets view handler at compile time. This tag has no attributes. You can use this tag to indicate that a particular tag should be removed from the rendered page.

It's useful to remove content which is required during design time, but not during run time, such as comments, some stubbed content (e.g. "lorem ipsum") which aids in filling up the page content to fit the layout in visual designers such as Dreamweaver, etc.

See: Practical implications of Facelets ui:remove tag

Note that the Facelets compilation process is much faster than the JSP compilation process because no Java bytecode is actually generated and compiled behind the scenes when you first visit your page. The UI Remove tag is used to specify tags or blocks of content that should be removed from your page by the Facelets view handler at compile time. This tag has no attributes.

Examples of both comment options

like image 40
Richard P. Avatar answered Oct 02 '22 17:10

Richard P.