Robert M.
Robert M.

Reputation: 1

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. 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(&quot;j_id1176210999_514e0f6c:j_id1176210999_514e0fad&quot;,event,{&quot;parameters&quot;:{&quot;javax.faces.behavior.event&quot;:&quot;keyup&quot;} } )" 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}" />

Upvotes: 0

Views: 8372

Answers (1)

Barbon
Barbon

Reputation: 41

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.

Solution:

Add the following tag to your JSF code:

<h:head/>

Upvotes: 4

Related Questions