1

I am running into a weird problem when using myfaces that is driving me nuts. I tried versions 2.2.10 and 2.2.12. I also use primefaces 6.0 but that might not be relevant.

Whenever I include an f:ajax tag on a page, commandLink no longer works and I get an error in the JavaScript console:

ReferenceError: myfaces is not defined

Digging deeper it turns out that the following line is no longer generated when there is a f:ajax tag on the page:

<script type="text/javascript" src="/console/javax.faces.resource/oamSubmit.js.jsf?ln=org.apache.myfaces"></script>

When I manually add this script line everything works again! I do this by adding the folling javascript just after the 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>

Although everything seems to be working fine with this hack it gives me an uneasy feeling to have to do this. Can anyone shed a light on the cause of this issue?

Pieter
  • 221
  • 2
  • 10

1 Answers1

1

Same issue here. I stumbled upon mojarra is not defined when javax.faces.PROJECT_STAGE is Production and submitForm() not defined for myfaces.JSF_JS_MODE 'minimal-modern' and found out that the issue is only present in javax.faces.PROJECT_STAGE=Production.

Adding

<context-param>
    <param-name>org.apache.myfaces.JSF_JS_MODE</param-name>
    <param-value>minimal</param-value>
</context-param>

to the web.xml fixed the issue for me.

charvi
  • 51
  • 6