aspose file tools*
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
Author

jsf convertNumber tag trailing Alphabatic char issue

Trip Sharma
Greenhorn

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"/>
</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

Joined: Jun 25, 2001
Posts: 16012
    
  19

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: http://aspose.com/file-tools
 
subject: jsf convertNumber tag trailing Alphabatic char issue