This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I have problem in validating double field..am using struts 1.3 and am manually validating the fields in my action class and not using any framework.. Issue is, I have declared a field 'double' in my formbean.
And if i enter any invalid characeter say, a string in the field, it is not throwing error, instead, it takes it as 0.0. How to avoid this..
The code looks OK and interestingly I'm not aware of this behavior, i.e converting to a default value rather than raising NuberFormatException in Struts 1.x.
Anyways, the quick solution will be to replace double with "String" property, and in getter, convert it into double
If, you want to keep it double, then I you have to use client side(JS) validation
Joined: Jul 01, 2009
Am not very much used to struts..
So how should my set method be?
The variables are double in my db too.. so, should i also have to convert and send???