Announcement Announcement Module
Collapse
No announcement yet.
Displaying Doubles Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Displaying Doubles

    I have an input field, in which a user can enter a Double. The problem is, users have to enter a Double with a comma (14,75). So far so good, when you enter a double 14,75, validation doesn't fail. I added a DecimalFormat to my NumberEditor and that works like a charm.

    However, when you submit the form, the page is redisplayed. When that happens, I believe the toString() method is called of the double. When that happens, the double is displayed as 14.75, instead of 14,75. If the user submits again, my DecimalFormat enters the picture, assumes that the '.' isn't valid and creates a new digit 1475.

    What I can do is use fmt:formatNumber to display the double correctly. But then I'm faced with another problem, namely when a user enters text in that field, the form should be displayed with an inputfield containing that text. When you use fmt:formatNumber, you'll get a ParseException.
Working...
X