RichFaces 4 -Javascript“未找到 RichFaces”
很抱歉问题标题,但我无法找出更好的问题标题。
我正在使用 JSF 2.0 (MyFaces 2.0.2) 并将 RichFaces 4 (4.0.0.20101004-M3) 添加到我的项目中。 我找到了一个 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>
由于这是一个 Facelets 页面,它使用一个定义标头的模板(包括徽标和主导航)。
如果我在浏览器中打开页面,它会正确呈现。输入框的 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">
问题是,如果我在文本框中输入一些内容,它应该使用名为“RichFaces.ajax(...)”的 Javascript 函数在每个按键上触发 ajax 请求。然而,每次触发该事件时,Firefox 错误控制台都会打印一个错误:
Error: RichFaces is not defined
Source File: http://localhost:8080/project/richEchoTest.xhtml
Line: 1
对于我的问题:有谁知道这个 RichFaces-Javascript-Object 是在哪里定义的吗?或者我必须在 xhtml 页面中包含什么内容?我只包含“xmlns:a4j =“http://richfaces.org/a4j”,我是否还必须添加“xmlns:rich....”?
提前致谢,我非常感谢任何帮助,因为我已经浪费了 3 天时间来研究这个问题。//
编辑: 我忘了提及,如果我使用内置的 jsf2 ajax 标签,它的工作方式就像一个魅力:
<f:ajax event="keyup" execute="@form" render="text count"
listener="#{echoBean.countListener}" />
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.
I found an example with RichFaces 4 (http://java.sys-con.com/node/1098139) and created a xhtml-page with the following code:
<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).
If i'm opening the page in my browser, it gets rendered correctly. The resulting HTML code of the inputbox is as follows:
<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(...)". However everytime the event is fired, the Firefox Error-Console prints an Error:
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? Or is there anything i have to include within the xhtml-pages? I only included the "xmlns:a4j="http://richfaces.org/a4j", do i have to add the "xmlns:rich...." too?
Thanks in advance, I'd really appreciate any help, cause I already wasted 3 days looking into the problem.
//EDIT:
I forgot to mention that if I use the built-in jsf2 ajax-tag it works like a charm:
<f:ajax event="keyup" execute="@form" render="text count"
listener="#{echoBean.countListener}" />
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此问题已在此链接中得到解决和评论。以下是相关性的摘录:
This problem was solved and commented in this link. Here's an extract of relevance: