我想在 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>
最佳答案
不要使用页脚文本。反而:
<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>
关于jsf-2 - 如何在 primefacs columnGroup 中设置货币格式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18908588/