I’m trying to run some basic javascript code with JSF 2.
I’m using the following code to do so:
<h:outputScript target="head">
var props = $.event.props;
</h:outputScript>
Looking at the source of the page I can’t find any evidence of this code.
I thought that was the correct way to work with javascript code in JSF.
Should I use the <script> tag of html instead?
Thanks!
That’s not the intend purpose of the
outputScripttag. It just renders an HTMLscripttag while resolving the location of the javascript file that’s specified in itsnameattribute.If you need to inline javascript, just enclose it in the
<script>tag directly.