Ahmed Nabil
Ahmed Nabil

Reputation: 19026

javax.faces.view.facelets.FaceletException: The string "--" is not permitted within comments

When try to add a TODO comment in a piece of JavaScript code in a Facelets file like that

<script type="text/javascript">
    <!--

    // TODO -- my comment
    function makeExecute() {                            

    }                       

    -->
</script>

then I face an exception:

javax.faces.view.facelets.FaceletException: Error Parsing /myScreen.xhtml: 
    Error Traced[line: 448] The string "--" is not permitted within comments.
        at com.sun.faces.facelets.compiler.SAXCompiler.doCompile(SAXCompiler.java:390)
        at com.sun.faces.facelets.compiler.SAXCompiler.doCompile(SAXCompiler.java:364)
        at com.sun.faces.facelets.compiler.Compiler.compile(Compiler.java:122)

How is this caused and how can I solve it?

Upvotes: 1

Views: 3288

Answers (2)

Coder
Coder

Reputation: 1899

Actually in the file; if double - is encountered, it considers the comment has ended!. The double - might as well be interspersed in the comments <!-- hello 1 - 2 - exit -->; so it will consider the comment ended after 2.

Solution. Get rid of any - in the comments, use other characters. It will make your life easier.

Upvotes: 1

Konstantin Yovkov
Konstantin Yovkov

Reputation: 62864

The stacktrace pretty much says it:

The string "--" is not permitted within comments.

As per definition:

A comment declaration starts with <!, followed by zero or more comments, followed by >. A comment starts and ends with --, and does not contain any occurrence of "--".

To get rid of the error, simply type a space between the -- in the comment (or remove it).

// TODO - - my comment

Upvotes: 5

Related Questions