문제

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>
도움이 되었습니까?

해결책

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.

다른 팁

If you are missing { in your el, you will get the error rich:component not found.

For a4j:commandButton

<a4j:commandButton value="Show" oncomplete="#{rich:component('chargePointDetailPopup')}.show()"/>

For a4j:ajax in commandLink

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

Make sure to rich:popupPanel

<rich:popupPanel id="chargePointDetailPopup">
......
</rich:popupPanel>

For more Reference

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top