1

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?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Ahmed Nabil
  • 17,392
  • 11
  • 61
  • 88
  • 1
    This is not a JavaScript problem. – Evan Davis Oct 05 '13 at 20:39
  • 3
    I have no idea *why* it's not allowed but your compiler is telling you why: "The string "--" is not permitted within comments." So the solution is to remove the string "--" from the comment... – Stephen Byrne Oct 05 '13 at 20:52
  • 2
    JavaScript code belongs in a `.js` file, not a `.xhtml` file. – BalusC Oct 06 '13 at 00:59
  • possible duplicate of [Cure for 'The string "--" is not permitted within comments.' exception?](http://stackoverflow.com/questions/10155940/cure-for-the-string-is-not-permitted-within-comments-exception) – Kevin Panko Feb 25 '15 at 19:50

2 Answers2

5

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
Konstantin Yovkov
  • 62,134
  • 8
  • 100
  • 147
1

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.

Coder
  • 1,415
  • 2
  • 23
  • 49
  • I'm not seeing what this answer adds up to the already given answer. You seem to be merely repeating/confirming the already given answer. In that case, you're supposed to upvote it instead of repeating it like as on an old fashioned discussion forum wherein everyone repeats each other into an undigestable mess upon agreement (which is exactly why Q&A sites like Stack Overflow were created). – BalusC Jan 22 '14 at 08:00
  • The accepted answer comments only on the case when a double `-` is encountered "together". It doesn't say if the `-` can be present with more than one occurrence; it can cause error. I think it was pretty obvious. – Coder Jan 22 '14 at 12:08