• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem using convertNumber for decimal numbers  RSS feed

 
camilla bat
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using a f:convertNumber on an inputText. I want the number that is typed to convert to a Double (or double). This is my inputText:

<f:inputText value="#{myBean.length}" >
<f:convertNumber pattern="####0.0"/>
</af:inputText>

The format of the input is supposed to be maximal 5 digits, and one decimal. If the user types e.g. 4, I want the converter to convert this to a Double 4.0. But it takes it as a Long, so I get a classCastException.

Is it possible at all to use this converter for my purpose: convert to a one decimal number. The pattern is maybe wrong?
 
Rajeev Ravindran
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i never tried pattern but i think this will server your purpose

<f:convertNumber maxFractionDigits="1" minFractionDigits="1" maxIntegerDigits="5" groupingUsed="false"/>

I hope you have defined 'length' as double in your managedbean.

Thanks,
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!