• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSF Validatuion to acquire only numeric values for an input field  RSS feed

 
vish som
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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.
 
Tim Holloway
Bartender
Posts: 18662
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!