我想在Primefaces
列组中设置货币格式,而不会获取字符串(货币格式)值JSF Backing Bean
。
如果无法在页面中设置货币格式,我将采用货币格式的字符串值,如下所示。
public String getCurrencyFormatString(Double value) {
DecimalFormat formatter = new DecimalFormat("##,###.00");
return formatter.format(value);
}
<p:dataTable id="paymentDataTable" var="payment" value="#{PaymentActionBean.paymentList}">
<!--Other six columns-->
<p:column headerText="Total">
<h:outputText value="#{payment.totalAmount}">
<f:convertNumber pattern="#{ApplicationSetting.currencyFormat}"/>
</h:outputText>
</p:column>
<p:columnGroup type="footer">
<p:row>
<p:column colspan="7" footerText="Total:" style="text-align:right"/>
<p:column footerText="#{PaymentActionBean.grandTotalAmount}" style="text-align:right">
<!--How Can I put number format (##,###.00) for grand total amount? -->
</p:column>
</p:row>
</p:columnGroup>
<p:dataTable>
答案 0 :(得分:3)
不要使用footerText。代替:
<p:columnGroup type="footer">
<p:row>
<p:column colspan="7" footerText="Total:" style="text-align:right"/>
<p:column style="text-align:right">
<f:facet name="footer">
<h:outputText value="#{PaymentActionBean.grandTotalAmount}">
<f:convertNumber pattern="##,###.00" />
</h:outputText>
</f:facet>
</p:column>
</p:row>
</p:columnGroup>