We had a similar issue. We have all our currencies defined as Doubles currently, but we would get errors on values that resolved to Longs (ex. 1.0). We had to create our own converter that always converted the Number to a Double.
We wanted to extend the existing number converter just like you mentioned, but I wasn't sure how to do that and still be able to pass parameters into the converter. Can you shed any light on this? Thanks, Geoff On 5/5/06, Mike Kienenberger <[EMAIL PROTECTED]> wrote:
On 5/5/06, Julian Ray <[EMAIL PROTECTED]> wrote: > How about creating a CurrencyConverter which would have configurable and > localizable currency formats as well as style for positive and negative > values etc. Is there any value in this? > > If we could drum up a list of requirements I would be willing to get it > started as I have to build one anyway in the very near future. Hey Julian, I think f:convertNumber can do all of this already. http://java.sun.com/javaee/javaserverfaces/1.2/docs/tlddocs/f/convertNumber.html The only problem with it is that it returns a Number (internally either a Long or Double - depending on the input), which means your backing beans must represent currency via Number getters and setters. I'm thinking that subclassing NumberConverter and coercing the type is probably all that's necessary. But since I'm using Facelets, I don't have a lot of interest in creating jsp tags and tlds and all that JSP support unless there's actual interest beyond my own personal use. Mario's idea of supporting configurable return types sounds good if this is going to become a public component.