Thursday, September 25, 2008

BigDecimal converters

After today it looks as if choosing to use BigDecimal (for whatever reason) may have a challenge with regard to having both automated conversion and using a pattern to format your numbers.

So it sounds like it is time create a custom converter which extends the BigDecimal converter from JSF, and putting numeric patterns on top of it.

I will let you know how it goes...

...OK: it went well: I discovered that the creators of the application I am working on had already created such a converter. So I just use f:converter component, and reference the id of this component that was created; since the custom converters must be registered in faces-config.xml, you can just get the id from there if you are utilizing a pre-existing custom converter.

It turns out this converter hard-coded the format string. So I just loaded the resource bundle with the format string in it and use that instead. That way there is only once source in the application for the desired format string.

No comments: