开发者

Can somebody give me an example of using jsf converters?

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 doubl开发者_开发知识库e.


  • implement javax.faces.convert.Converter
  • in the getAsString(..) method use object.toString()
  • in the getAsObject(..) method use new BigDecimal(str) / Double.parseDouble(str) / Integer.parseInt(str). Use instanceof to differentiate between the types.
  • register the converter in faces-config.xml.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜