• 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 Validatuion to acquire only numeric values for an input field

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello
I hav an input text in my JSP which obtains value from the user.The name of the field is "Volume" and it is a 'double' datatype in my backing bean.The user entered value is to be set as the double value in the setter.


I need to ensure that only numeric values can be obtained from the user.The non numeric values from the user should throw a validation error.How can this be done using validators in JSF?
Thanks
 
vish som
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have been trying out clues from the link : http://www.ibm.com/developerworks/java/library/j-jsf3/
But when i implement

I get the following error on my jsp page


javax.faces.FacesException: /jsp/ml/freeway-page.jsp(183,1) Attribute id invalid for tag converter according to TLD
caused by:
org.apache.jasper.JasperException: /jsp/ml/freeway-page.jsp(183,1) Attribute id invalid for tag converter according to TLD
 
vish som
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I changed the code with this



and it worked!

Reason :The <f:converter> doesn't have an id attribute: http://java.sun.com/javaee/javaserverfaces/1.2_MR1/docs/tlddocs/f/converter.html.
 
Saloon Keeper
Posts: 27752
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
Actually, the "id" attribute is a basic feature of XML. However, its value has to follow the proper rules for ID formation - you can't just put arbitrary strings into IDs.
 
vish som
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tim
Are you pointing to the id i have used for converter or for the inputText?
Can you please correct the above snippet with the best practice.I would surely like to adopt that methodology.

Thanks
 
incandescent light gives off an efficient form of heat. You must be THIS smart to ride this ride. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic