【问题标题】:Using Omnifaces EL functions in composite component with Mojarra 2.2.5在 Mojarra 2.2.5 的复合组件中使用 Omnifaces EL 函数
【发布时间】:2014-01-27 15:35:04
【问题描述】:

升级到 JSF Mojarra 2.2.5 后,使用 Omnifaces 的 el 函数 formatNumber 时出现以下异常。这仅发生在复合组件内。普通 Facelet 工作正常。

javax.el.E​​LException: 找不到函数'of:formatNumber'

这是我的复合组件:

<?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>

提前感谢您的帮助:)

编辑: 如果我使用来自cc.attrs.* 的值,就会出现问题。如果我直接使用该值作为属性,那么一切都运行良好。有什么想法吗?

编辑2: 以下代码可以解决问题

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

但这很丑。我找不到我的错误。

【问题讨论】:

  • 让我想起了一个旧的 Mojarra 错误。如果将xmlns:of="http://omnifaces.org/functions" 放入&lt;cc:implementation&gt; 会发生什么?
  • 是的,我找到了关于这个的旧线程。但是将命名空间声明放在 implementation 标记中没有任何区别。
  • 很奇怪。让我在 2.2.5 上试试吧……
  • 嗯,对我有用。哪个 OmniFaces 版本和哪个容器制造/版本?以前对您有用的旧 Mojarra 版本是什么?

标签: composite-component jsf-2.2 omnifaces


【解决方案1】:

我创建的问题被标记为不会修复,因为有一个解决方法:

#{foo} 类型的所有方便的内联el 调用替换为&lt;h:outputText value="#{foo}"/&gt;

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

非常不方便和麻烦。 2.2.4 -> 2.2.5 的许多回归。

【讨论】:

    猜你喜欢
    • 2012-12-29
    • 2018-06-19
    • 2013-08-04
    • 2017-09-21
    • 1970-01-01
    • 2012-11-24
    • 2014-03-07
    • 2013-01-11
    • 2019-08-02
    相关资源
    最近更新 更多