Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsf convertNumber tag trailing Alphabatic char issue

 
Trip Sharma
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using jsf convertNumber tag to convert the input number as well validate it,
the prob is when I input the trailing char as Alpha
example: 12345.123AAA get converted into 12345.123
<h:textField binding="#{test$SomeBean.someField}" id="someField" style="width: 168px">
<f:convertNumber minFractionDigits="2"/>
</h:textField>
how can i fail the conversion if it has alpha char in it, its only happening in case of trailing char as alphabatic
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18212
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Trip!

What you really need is something that validates before conversion is attempted. Your problem is that convertNumber is using the stock Java numeric construct/convert methods, which tend to ignore the non-numeric stuff. You probably cannot use the "pattern" attribute - I think that it only applies to the number part of the input.

I was thinking that there was a regular-expression validator that could be used, but I couldn't find it in the JSF 1.x docs. It is definitely available in JSF2, though.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic