【发布时间】:2014-01-27 15:35:04
【问题描述】:
升级到 JSF Mojarra 2.2.5 后,使用 Omnifaces 的 el 函数 formatNumber 时出现以下异常。这仅发生在复合组件内。普通 Facelet 工作正常。
javax.el.ELException: 找不到函数'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"放入<cc:implementation>会发生什么? -
是的,我找到了关于这个的旧线程。但是将命名空间声明放在 implementation 标记中没有任何区别。
-
很奇怪。让我在 2.2.5 上试试吧……
-
嗯,对我有用。哪个 OmniFaces 版本和哪个容器制造/版本?以前对您有用的旧 Mojarra 版本是什么?
标签: composite-component jsf-2.2 omnifaces