jheider
jheider

Reputation: 121

Using Omnifaces EL functions in composite component with Mojarra 2.2.5

After upgrading to JSF Mojarra 2.2.5, i get the following exception when using Omnifaces's el function formatNumber. This only occurs within a composite component. Normal Facelet is working fine.

javax.el.ELException: Function 'of:formatNumber' not found

this is my composite component:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:jsf="http://xmlns.jcp.org/jsf"
      xmlns:cc="http://xmlns.jcp.org/jsf/composite"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:of="http://omnifaces.org/functions">

    <cc:interface>
        <cc:attribute name="cart" required="true" type="org.ead.eeb.order.ShoppingCart" />
        <cc:attribute name="allowCouponRemove" required="true" type="java.lang.Boolean" />
        <cc:attribute name="removeCouponBean" type="java.lang.Object" />
        <cc:attribute name="removeCouponAction" type="java.lang.String" />
        <cc:attribute name="removeCouponProperty" type="java.lang.String" />
    </cc:interface>

    <cc:implementation>
        <h4>Übersicht</h4>
        <table class="table">
            <tbody>
                <c:forEach items="#{cc.attrs.cart.items}" var="item">
                    <tr>
                        <td><abbr title="#{item.description}">#{item.name}</abbr></td>
                        <td class="text-right">#{of:formatNumber(item.totalAmount, '#0.00')}  €</td>
                    </tr>
                </c:forEach>
                <tr>
                    <td>Mehrwertsteuer (#{cc.attrs.cart.taxRatePercentage} %)</td>
                    <td class="text-right">#{of:formatNumber(cc.attrs.cart.totalTax, '#0.00')} €</td>
                </tr>
            </tbody>
            <tfoot>
                <tr class="active">
                    <td><strong>Gesamtbetrag</strong></td>
                    <td class="text-right"><strong>#{of:formatNumber(cc.attrs.cart.totalOrderAmount, '#0.00')} €</strong></td>
                </tr>
            </tfoot>
        </table>
        ...
    </cc:implementation>

thanks in advance for your help :)

Edit: the problem occurs, if i use the value from cc.attrs.*. If I use the value directly as an attribute, everthing is working well. Any ideas?

Edit2: A workaround is possible by the following code

<c:set var="test" value="#{cc.attrs.value}" />
#{of:formatNumber(test, '#0.00')} 

but that's pretty ugly. I can't find my mistake.

Upvotes: 2

Views: 924

Answers (1)

djmj
djmj

Reputation: 5544

The issue i created was marked as Wont't Fix, since there is a workaround:

Replacing all convenient inline el calls of type #{foo} with <h:outputText value="#{foo}"/>.

https://java.net/jira/browse/JAVASERVERFACES-3469

Very inconvenient and cumbersome. Many regressions from 2.2.4 -> 2.2.5.

Upvotes: 1

Related Questions