File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes jsf convertNumber tag trailing Alphabatic char issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "jsf convertNumber tag trailing Alphabatic char issue" Watch "jsf convertNumber tag trailing Alphabatic char issue" New topic

jsf convertNumber tag trailing Alphabatic char issue

Trip Sharma

Joined: Jun 28, 2012
Posts: 1
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"/>
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

Joined: Jun 25, 2001
Posts: 15957

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.

Customer surveys are for companies who didn't pay proper attention to begin with.
I agree. Here's the link:
subject: jsf convertNumber tag trailing Alphabatic char issue
Similar Threads
[convertNumber] currencySymbol and hex code
convertNumber question
How do I NOT require currency symbol on input, but still display it with convertNumber?
convertNumber and currencySymbol
convertNumber and rounding mode