JSF converter with null value

前端 未结 1 865
你的背包
你的背包 2021-01-22 04:02

I need to convert null property values of type java.math.BigDecimal to 0.00 everywhere with a specified number of decimal places (only for

相关标签:
1条回答
  • 2021-01-22 04:48

    This is specific to the Mojarra. The problem occurred because the converter is not called when the value is null (see source here). I tested the same code in the MyFaces implementation and the result is that the convert is always called, no matter if the value is null (as can be seen here, line 378).

    So if change JSF implementation is not an option, I think the solution through OmniFaces is good enough. At worst, maintain a function that makes the conversion like #{convert(bean.value)} may leave cleaner your view than an inline comparison.

    0 讨论(0)
提交回复
热议问题