JavaScript

Problem

If you use in the header section of a Facelets XHTML page JavaScript with uncoded special characters & or <, it results in one of the following error messages:

com.sun.facelets.FaceletException: Error Parsing forum.xhtml: Error Traced[line: 10] The content of elements must consist of well-formed character data or markup.

com.sun.facelets.FaceletException: Error Parsing forum.xhtml: Error Traced[line: 10] The reference to entity "forum" must end with the ';' delimiter.

com.sun.facelets.FaceletException: Error Parsing forum.xhtml: Error Traced[line: 10] The entity name must immediately follow the '&' in the entity reference.

Solution

Of course encoding of the special characters with XHTML entities &amp; and &lt; would be one solution. But if the code should still remain readable in comparison and mathematical functions, you can integrate the total JavaScript block inside a CDATA section.

<script type="text/javascript"> //<![CDATA[ ... url = 'forum?id=111&topic=222'; if ((forum > 1) && (forum < 10)) ... //]]> </script>

Resources

[1] JSF 1.2
[2] Mojarra 1.2_14

Johannes Hammoud JavaScript 23.04.2012

I Coding : Community about Java programing

Language German+-

Java JSF JavaScript HTML CSS NetBeans GlassFish MySQL

Imprint

Visits
5744523
Today
92