File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes double validation not catching text Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "double validation not catching text" Watch "double validation not catching text" New topic

double validation not catching text

K Dombroski
Ranch Hand

Joined: Dec 03, 2005
Posts: 39
I'm trying to use the struts validator (using struts 1.2.7) to make sure the user enters a double value in a given range. When I enter a number outside the given range, I get the error as expected. But when I enter text, such as "hgl," I don't get any errors. "hgl" cannot be converted to a Double, so why is the validator not catching it? I am at a loss. If anyone can help, I'd be grateful.

Here is my validation:
<field property="financialFile.useTaxRate"
<arg0 key="Financial File: Use Tax Rate"
resource="false" />
<arg1 name="doubleRange" key="${var:min}" resource="false"/>
<arg2 name="doubleRange" key="${var:max}" resource="false"/>
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
What does your form look like? If you do not have your properties there defined as Strings then the validation framework cannot detect invalid entries.

- Brent
K Dombroski
Ranch Hand

Joined: Dec 03, 2005
Posts: 39
I have useTaxRate defined as a double in my form. Will that not work?
I agree. Here's the link:
subject: double validation not catching text
It's not a secret anymore!