HTML comments ignored in facelets

If you are new to facelets you may be wondering why you still receive errors in your deployed web application because of some code already commented out with <!−−  −−> in your xhtml file.

<div class="actionButtons">
<!−−
<a4j:commandButton action="#{b.login}"/>
−−>
</div>

The reason is that text surrounded by these comments is not simply ignored when the facelet is processed to generate the HTML response. In fact the text is interpreted and encoded as HTML comment into the response. So any JSF Expression Language (EL) in your comment will be executed!

In the example above the method binding #{b.login} will be interpreted. To avoid this you can use a special tag <ui:remove> provided by Facelets to ignore blocks of template markup.

<div class="actionButtons">
<ui:remove>
<a4j:commandButton action="#{b.login}"/>
</ui:remove>
</div>
Dieser Beitrag wurde unter IT abgelegt und mit , , , , , , , , verschlagwortet. Setze ein Lesezeichen auf den Permalink.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.