I have a JavaScript file stored in the web root like,
SocialNetworking/web/resources/js/decimal_number_text_field.js
I'm trying to import this js file in an XHTML page like,
<h:body>
<ui:composition template="template/Template.xhtml">
<ui:define name="content">
<h:outputScript name="../resources/js/decimal_number_text_field.js"/>
</ui:define>
</ui:composition>
</h:body>
The path is correct but it doesn't work.
The generated JavaScript tag looks like the following.
<script type="text/javascript" src="/SocialNetworking/javax.faces.resource/../resources/js/decimal_number_text_field.js.jsf">
</script>
So, the src
attribute contains a wrong URL. If this script is added to the template within the <h:head>
tag like so,
<h:outputScript name="js/decimal_number_text_field.js"/>
then it works fine.
Why does it take a wrong URL when this tag is placed in an XHTML page which covers the template?