tags:

views:

88

answers:

3

How can I set precision for such EL result?

<h:outputText value="#{businessPlanPreviewBean.plan.a1 != 0 ?
 businessPlanPreviewBean.plan.a2/businessPlanPreviewBean.plan.a3 : 0 } " >
</h:outputText>

I tried <f:convertNumber maxFractionDigits="2" /> but no luck...

<f:convertNumber pattern="#,##" /> - the same thing

Mojarra JSF implementation version 1.2_14-b01-FCS

A: 

Have you tried the pattern attribute ?

thelost
Yes, the same thing
Dmitry Demidenko
A: 

The <f:convertNumber maxFractionDigits="2" /> should work. Did you place it inside the <h:outputText>? What JSF impl/version are you using? Tried the latest version?


Update: if you want to display it as a currency, use the following:

<f:convertNumber type="currency" currencySymbol="$" />

Or if you want to have fractions for round numbers as well, use the following:

<f:convertNumber pattern="#.##" />
BalusC
Yes, its inside <h:outputText>. Sun JSF implementation version 1.2_14-b01-FCS. I will try the latest version soon.
Dmitry Demidenko
A: 

The issue was very simple. "value" attribute contains unnecessary space at the end. So, value has string type in this case.

String cannot be formatted with f:convertNumber.

Dmitry Demidenko