I have below code in one (main) Facelets page,
<h:panelGroup rendered="true">
<ui:insert>
<ui:include src="/includeSecondPage.xhtml" />
</ui:insert>
</h:panelGroup>
Below is the content in includeSecondPage.xhtml page,
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core">
<head>
<script type="text/javascript">
/* <![CDATA[ */
function myScript ()
{
alert("Inside myScript");
}
myScript();
/* ]]> */
</script>
</head>
<f:view>
<body>
<h:form id="secondForm">
<ui:composition>
<h:outputText value="This panel is called using Component Control Component"></h:outputText>
</ui:composition>
</h:form>
</body>
</f:view>
</html>
My Java Script is not getting called in my includeSecondPage.xhtml. Alert box is not popping up in my first (main) page which includes this second page. And there are no Java Script errors in Java Script console.