How to avoid "$" and "#" in Facelets / EL?

I use Java Facelets and jQuery however the expression

$('...') 

in jQuery conflicts with EL expression, how can I avoid jQuery?

I would also like to get rid of a large piece of Javascript.

ANSWERED

To convert an existing JSP to Facelets xhtml, it’s convenient to simply wrap the existing javascript <![CDATA[ ... ]]> . However, the output scripts for <script> wrapped with a comment <!-- --> , which conflicts with the CDATA section:

 <script><![CDATA[ scripts... ]]></script> => <script><!-- <![CDATA[ scripts... ]]> --></script> 

To solve this problem, you should also comment on CDATA:

 <script>/* <![CDATA[ */ scripts... /* ]]> */</script> => <script><!-- /* <![CDATA[ */ scripts... /* ]]> */--></script> 

See also When is a CDATA section needed in a script tag? .

+6
source share
2 answers

This usually does not conflict. EL uses the syntax ${} . In any case, you can use jQuery() ( $() is just a shorthand) or just put the JS code in your own .js file.

+3
source

If anyone needs it, the Maintenance Release Expression Language Version 2.2 version describes how to avoid EL expressions:

To generate literal values ​​that include the sequence of characters "${" or "#{" , the developer can choose to use a compound expression, as shown here:

 ${'${'}exprA} #{'#{'}exprB} 

The resulting values ​​will then be the lines ${exprA} and #{exprB} .

Alternatively, the escape characters \$ and \# can be used to exit, which would otherwise be considered an Eval expression. Given literal expressions:

 \${exprA} \#{exprB} 
+11
source

Source: https://habr.com/ru/post/885617/


All Articles