I've encountered a frustrating issue while using MyFaces that is really getting on my nerves. I have tried versions 2.2.10 and 2.2.12, along with PrimeFaces 6.0, although the latter may not be relevant.
Every time I add an f:ajax tag to a page, my commandLink stops working and I receive a JavaScript console error:
ReferenceError: myfaces is not defined
After some investigation, I discovered that the following line is not generated when there is an f:ajax tag present on the page:
<script type="text/javascript" src="/console/javax.faces.resource/oamSubmit.js.jsf?ln=org.apache.myfaces"></script>
To workaround this issue, I manually insert this script line by adding the following JavaScript right after the <head> tag:
<script>
if (!window.myfaces) {
document.write(unescape('%3Cscript type="text/javascript" src="/console/javax.faces.resource/oamSubmit.js.jsf?ln=org.apache.myfaces"%3E%3C/script%3E'));
}
</script>
While this hack seems to resolve the problem, it leaves me feeling uneasy having to resort to such a workaround. Can anyone provide insight into what might be causing this issue?