Michael
Michael

Reputation: 1237

Managed bean method still invoked when commenting out a JSF tag using HTML comments

I'm developing a web application in Java EE 7 using JSF 2.0 which is deployed on a GlassFish 4 server.

I've created a page that contained JSF tags and after a while decided to comment out a commandLink that had a call to a managed bean method using <!-- -->

I found that this method will execute regardless of the comment.

Is this a normal behavior or am I doing something wrong?

Upvotes: 1

Views: 610

Answers (2)

Alexandre Jacob
Alexandre Jacob

Reputation: 3041

Instead of using regular XML comment you can use <ui:remove> which wont fire the event of your commandButton. Moreover, everything inside <ui:remove> won't be put in the generated HTML.

Example :

<ui:remove>
    <h:commandButton ... />
</ui:remove>

Upvotes: 2

ibecar
ibecar

Reputation: 415

you have to set flag to skip comments:

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

otherwise will your code in comments executed regardless of comment tag

Upvotes: 2

Related Questions