如何在primefaces的columnGroup中设置货币格式?

5

我希望在Primefaces列组中设置货币格式,而无需从JSF后端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>

试着阅读这个链接:http://forum.primefaces.org/viewtopic.php?f=3&t=5880 - miroslav_mijajlovic
但是需要一些自定义代码。 - Pushkar
1个回答

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>

这个选择应该在Primefaces展示中心里展示! - jpangamarca

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接