什么可能导致“jsf未定义”浏览器控制台错误 [英] What can cause "jsf is not defined" error in browser console

查看:83
本文介绍了什么可能导致“jsf未定义”浏览器控制台错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨我在Tomcat 6上有一个基于MyFaces 2.0.11和Primefaces 3.0的简单新项目

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

当我试图导航到一个页面时我是获取未捕获的ReferenceError:jsf未定义错误,它将我引导到我的js代码中的ref jsf.ajax.addOnEvent ...(这是合理的,因为我正在尝试使用jsf.js并且它不是活动现在我是我的页面..)

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..)

如果我这样做的话查看我的页面的来源我不包含 jsf.js 文件

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.jslibrary =javax.facestarget =head/>

每件事情都很好......但我不想手动包含它,相反我想知道是什么原因可能导致我页面中缺少jsf.js

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

我确实有< h:head> < h:body> 我的页面非常简单...

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

任何想法?

推荐答案

只要您使用 < f:ajax> 。如果你不这样做,那么它就不会被自动包含。

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.

在你打电话给 jsf.ajax.addOnEvent之前,只需添加一个额外的支票。

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

或者,通过< h明确包含库正确的上的:outputScript> ,就像你已经做的那样。

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

这篇关于什么可能导致“jsf未定义”浏览器控制台错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆