Display formatted decimal numbers in Primefaces 4

2019-05-14 21:12发布

问题:

This question already has an answer here:

  • Displaying a number in 2 point decimal format in jsf 1 answer

I have a database table with a float field and I want to display it through Primefaces. I want to display the numbers formatted as (one thousand, for example): 1.000,00 I tried:

<p:column sortBy="#{item.value}" filterBy="#{item.value}">
  <f:facet name="header">
    <h:outputText value="#{epoBundle.ListUpbTitle_value}"/>
  </f:facet>
<h:outputText value="#{item.value}"/>
<f:convertNumber pattern="#0.000" locale="pt_BR"/>
</p:column>

But got: /WEB-INF/include/entity/upb/List.xhtml @80,55 Parent not an instance of ValueHolder: org.primefaces.component.column.Column@13ec99d0

Can someone help me?

Thanks in advance.

回答1:

f:convertNumber must be inside h:outputText.

<h:outputText value="#{item.value}">
    <f:convertNumber pattern="#0.000" locale="pt_BR"/>
</h:outputText>