admin管理员组

文章数量:1287584

Hi I got a simple fresh project based on MyFaces 2.0.11 with Primefaces 3.0 on Tomcat 6

When I'm trying to navigate to a page I'm getting Uncaught ReferenceError: jsf is not defined error which directs me to a ref in my js code jsf.ajax.addOnEvent ... (which is reasonable cause I'm trying to use the jsf.js and it's not event present I'm my page..)

And if I do view source of my page I dont the the include of the jsf.js file

Now if I add it manually like this

<h:outputScript name="jsf.js" library="javax.faces" target="head"/>

every thing works just fine... but I prefer not to include it manually , Instead I would like to know what are the reasons that can cause the lack of the jsf.js in my page

I google for a while and none of the similar case represents mine

I do have <h:head> and <h:body> My page is really simple...

Any Ideas?

Hi I got a simple fresh project based on MyFaces 2.0.11 with Primefaces 3.0 on Tomcat 6

When I'm trying to navigate to a page I'm getting Uncaught ReferenceError: jsf is not defined error which directs me to a ref in my js code jsf.ajax.addOnEvent ... (which is reasonable cause I'm trying to use the jsf.js and it's not event present I'm my page..)

And if I do view source of my page I dont the the include of the jsf.js file

Now if I add it manually like this

<h:outputScript name="jsf.js" library="javax.faces" target="head"/>

every thing works just fine... but I prefer not to include it manually , Instead I would like to know what are the reasons that can cause the lack of the jsf.js in my page

I google for a while and none of the similar case represents mine

I do have <h:head> and <h:body> My page is really simple...

Any Ideas?

Share Improve this question edited Apr 2, 2012 at 13:53 BalusC 1.1m376 gold badges3.6k silver badges3.6k bronze badges asked Apr 2, 2012 at 6:44 DanielDaniel 37.1k10 gold badges122 silver badges204 bronze badges 2
  • If you have a h:head on your page the script should be there. Check if it isn't skipped somehow by putting eg a title inside it. – Mike Braun Commented Apr 2, 2012 at 8:24
  • Added title... title is being display properly but the jsf.js still isn't being added... – Daniel Commented Apr 2, 2012 at 9:05
Add a ment  | 

1 Answer 1

Reset to default 8

This script will only be auto-included whenever you use <f:ajax> in the view. If you don't, then it won't be auto-included.

Just add an extra check before you call jsf.ajax.addOnEvent:

if (typeof jsf !== 'undefined') {
    jsf.ajax.addOnEvent(someFunctionName);
}

Or, explicitly include the library by <h:outputScript> on the proper library, like as you already did.

本文标签: javascriptWhat can cause quotjsf is not definedquot error in browser consoleStack Overflow