Search code examples
jsfnamespacesrichfaceselcomposite

'rich:component' not found: a4j:ajax with a composite component


I've built a simple composite component - a "richer" commandLink. I want it to support the clientBehavior, but when there is a <a4j:ajax> attached to the component I sometimes get the exception: ELException: Function 'rich:component' not found

It only comes when I use #{rich:component('...')} inside any attribute of <a4j:ajax>. For example oncomplete="#{rich:component('...')}.show()"

Edit: I am getting a Server error, not a JavaScript error.

The composite component (simplified):

<composite:interface>
    <composite:attribute name="style" />
    <composite:clientBehavior name="click" event="action" targets="commandLink" default="true"/>
</composite:interface>

<composite:implementation>
    <h:commandLink id="commandLink" style="#{cc.attrs.style}">
        <!-- my custom component content -->
    </h:commandLink>
</composite:implementation>

The problematic use of this component looks like this:

<myLib:commandLink value="Custom CmdLink">
    <a4j:ajax render="@form" execute="@form"
        oncomplete="#{rich:component('myEditPopup')}"/>
</myLib:commandLink>

But the following code works like a charm:

<h:commandLink value="test">
    <a4j:ajax render="@form" execute="@form"
        oncomplete="#{rich:component('myEditPopup')}.show()"/>
</h:commandLink>

Edit: This one works too:

<a4j:ajax render="@form" execute="@form"
    oncomplete="#{rich:component('myEditPopup')}.show()">
    <myLib:commandLink value="label"/>
</a4j:ajax>

Solution

  • It seems to be a bug in Mojarra (we have been using the version 2.1.6), that EL lost the namespace "rich". A working workaround was to declare the namespace in the a4j:ajax tag for each use:

                    <myLib:commandLink value="Show">
                        <a4j:ajax render="@form" execute="@form" xmlns:rich="http://richfaces.org/rich"
                                  oncomplete="#{rich:component('myEditPopup')}.show()"/>
                    </myLib:commandLink>
    

    After updating Mojarra to 2.1.26 the problem is gone and no needs for this workaround.