• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jsf convertNumber tag trailing Alphabatic char issue

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic