This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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

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’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: double validation not catching text
It's not a secret anymore!