Outcommented Facelets code still invokes EL expressions like #{bean.action()} and causes javax.el.PropertyNotFoundException on #{bean.action}
Solution 1:
Look closer at the stack trace. Here's the relevant part:
...
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:189)
com.sun.faces.facelets.el.ELText$ELTextVariable.toString(ELText.java:217)
com.sun.faces.facelets.el.ELText$ELTextComposite.toString(ELText.java:157)
com.sun.faces.facelets.compiler.CommentInstruction.write(CommentInstruction.java:77)
...
It's thus evaluating EL in a comment block (recognizable by CommentInstruction
). A comment block is considered as template text. Facelets evaluates by default also EL #{}
in template text. It's like as if you're writing <p>#{screenShotBean.takeScreenshot}</p>
without any JSF tag.
You've several options:
Remove the comment block altogether.
-
Escape EL expressions in the comment by prefixing it with
\
as in\#{screenShotBean.takeScreenshot}
so that they won't be evaluated.
Wrap the entire comment block in
<ui:remove>
so that it doesn't appear in the component tree (nor in the generated HTML output).-
Disable parsing of all comments by Facelets by adding the following context parameter to
web.xml
:<context-param> <param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name> <param-value>true</param-value> </context-param>
Note that no one comment will end up in generated HTML output this way.
Solution 2:
In addition to the options BalusC already provided you could also add the attribute rendered="false"
to your commandLink
.
If you have several components you want to be able to toggle quickly, you might want to consider creating a debug property in a bean or use the project stage:
rendered="#{facesContext.application.projectStage == 'Development'}"
Solution 3:
You could also use the context parameter that skips comments in your web.xml.
This is the parâmeter:
javax.faces.FACELETS_SKIP_COMMENTS