[英]RichFaces 4 - <a4j:ajax …> Javascript “RichFaces not found”
Sorry for the question title, but I couldn't figure out a better one. 对不起,这个问题的标题,但是我找不到更好的标题。
I'm using JSF 2.0 (MyFaces 2.0.2) and added RichFaces 4 (4.0.0.20101004-M3) to my project. 我正在使用JSF 2.0(MyFaces 2.0.2),并将RichFaces 4(4.0.0.20101004-M3)添加到我的项目中。 I found an example with RichFaces 4 (http://java.sys-con.com/node/1098139) and created a xhtml-page with the following code: 我找到了RichFaces 4(http://java.sys-con.com/node/1098139)的示例,并使用以下代码创建了xhtml页面:
<ui:define name="webpage_main_body">
<h:form>
<h:panelGrid columns="2">
<h:outputText value="Text:" />
<h:inputText value="#{echoBean.text}">
<a4j:ajax event="keyup" render="text,count"
listener="#{echoBean.countListener}" />
</h:inputText>
<h:outputText value="Echo:" />
<h:outputText id="text" value="#{echoBean.text}" />
<h:outputText value="Count:" />
<h:outputText id="count" value="#{echoBean.count}" />
</h:panelGrid>
</h:form>
</ui:define>
As this is a Facelets page, it uses a template which defines a header (including a logo and the main navigation). 因为这是Facelets页面,所以它使用定义标题的模板(包括徽标和主导航)。
If i'm opening the page in my browser, it gets rendered correctly. 如果我在浏览器中打开页面,它将正确呈现。 The resulting HTML code of the inputbox is as follows: 输入框的结果HTML代码如下:
<input type="text"
onkeyup="RichFaces.ajax("j_id1176210999_514e0f6c:j_id1176210999_514e0fad",event,{"parameters":{"javax.faces.behavior.event":"keyup"} } )" value="" name="j_id1176210999_514e0f6c:j_id1176210999_514e0fad" id="j_id1176210999_514e0f6c:j_id1176210999_514e0fad">
The problem is, if I enter something into the textbox, it should fire an ajax-reqest on every keyup using a Javascript-function called "RichFaces.ajax(...)". 问题是,如果我在文本框中输入内容,它应该使用名为“ RichFaces.ajax(...)”的Javascript函数在每次键入键时触发ajax请求。 However everytime the event is fired, the Firefox Error-Console prints an Error: 但是,每次触发事件时,Firefox Error-Console都会打印一个错误:
Error: RichFaces is not defined
Source File: http://localhost:8080/project/richEchoTest.xhtml
Line: 1
To my question: Has anyone have an idea where this RichFaces-Javascript-Object is defined? 我的问题是:有谁知道定义RichFaces-Javascript-Object的位置? Or is there anything i have to include within the xhtml-pages? 还是我必须在xhtml页面中包含任何内容? I only included the "xmlns:a4j="http://richfaces.org/a4j", do i have to add the "xmlns:rich...." too? 我只包含了“ xmlns:a4j =“ http://richfaces.org/a4j”,我也必须添加“ xmlns:rich ....”吗?
Thanks in advance, I'd really appreciate any help, cause I already wasted 3 days looking into the problem. 在此先感谢您,非常感谢您的帮助,因为我已经浪费了3天的时间调查问题。
//EDIT: I forgot to mention that if I use the built-in jsf2 ajax-tag it works like a charm: //编辑:我忘了提到,如果我使用内置的jsf2 ajax-tag,它的工作原理就像一个魅力:
<f:ajax event="keyup" execute="@form" render="text count"
listener="#{echoBean.countListener}" />
This problem was solved and commented in this link . 该问题已解决,并在此链接中进行了评论。 Here's an extract of relevance: 这是相关的摘录:
Cause : 原因 :
The browser can't find references to JS and CSS libraries of RichFaces. 浏览器找不到对RichFaces的JS和CSS库的引用。
Solution : 解决方案 :
Add the following tag to your JSF code: 将以下标记添加到您的JSF代码中:
<h:head/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.