I want to convert the text entered by someone into a textbox into a double(for example), and automatically set up the value of an bean field with that double.
,
- implement
javax.faces.convert.Converter
- in the
getAsString(..)
method useobject.toString()
- in the
getAsObject(..)
method usenew BigDecimal(str)
/Double.parseDouble(str)
/Integer.parseInt(str)
. Useinstanceof
to differentiate between the types. - register the converter in faces-config.xml.