Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set Currency Format in primefacs columnGroup?

I would like to set currency format in Primefaces column group without getting string (with currency format) value form JSF Backing Bean.

If there is no way to set currency format in the page, I will take string value with currency format as below.

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>
like image 686
Zaw Than oo Avatar asked Oct 21 '22 00:10

Zaw Than oo


1 Answers

Don't use footerText. Instead:

<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>
like image 62
dforce Avatar answered Oct 29 '22 05:10

dforce