• Post Reply Bookmark Topic Watch Topic
  • New Topic

confused in converter

 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't get the concept on Converter.



Above code works exactly as expected without the use of converter. When you enter integer or float, no issue, otherwise gives error 'Conversion error occured'.

I am just wondering what is the use of javax.faces.Float converter then?

BTW, isBean is float in ABean class.
 
Bob Good
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can do things like this:

 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bob Good:
you can do things like this:



And what does this doing? Purpose?
 
Ketan Jambhekar
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
One of the reason why you might want to use the converter is to alter the way you might want to display your data without actually modifying the object.
For eg. you can use a DateConverter and use a Date Object to display dates in various formats.
Similarly with the converter you have mentioned you can use to restrict the number of fractional digits.

Ketan.
 
Bob Good
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It edits and formats for you, in this example:
1) Only allow integers, no decimals
2) Maximum value is 9999999999
3) Minimum value is 0 (no negative numbers)

You get field messages like this:

Validation Error: Specified attribute is not between the expected values of 0 and 9,999,999,999.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!