我想在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>
Run Code Online (Sandbox Code Playgroud)
不要使用页脚文本。反而:
<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>
Run Code Online (Sandbox Code Playgroud)