aspose file tools*
The moose likes Struts and the fly likes Struts Validator-Validating an Integer Form Field Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts Validator-Validating an Integer Form Field" Watch "Struts Validator-Validating an Integer Form Field" New topic
Author

Struts Validator-Validating an Integer Form Field

Anitha Lingam
Ranch Hand

Joined: Apr 21, 2002
Posts: 38
Hi,
I have an integer form field. In my ActionForm I extend the ValidatorForm and i'm trying to Validate that field.
My validation.xml for that integer field looks like this
<field property="vcoord"
depends="required,integer">
<arg0 key="vcoord"/>
</field>
When i enter my jsp page, this field is automatically set to 0.
Even when i remove the 0 and perform the operation , validation doesn't happen. Instead the field is set back to 0.
The same problem occurs when i try to enter a string to the integer field and validate it. i.e..it doesn't validate telling that it is not an integer instead the value is set back to 0.
Can anybody help??
Thanks in advance.
sandy gupta
Ranch Hand

Joined: Jan 30, 2001
Posts: 228
In the jsp where you define the field, do you have a value=0?


Adios
Anitha Lingam
Ranch Hand

Joined: Apr 21, 2002
Posts: 38
No i haven't set any value
This is how it looks
<html:text property="vcoord" maxlength="5" size="6"/>
Jimmy Soh
Greenhorn

Joined: Dec 04, 2003
Posts: 5
solution
Jimmy Soh
Greenhorn

Joined: Dec 04, 2003
Posts: 5
Of course, it should be convertNull instead of converNull.
Giulietta Blumarine
Ranch Hand

Joined: Dec 03, 2004
Posts: 59
Hi!
I have the same problem of Anitha Lingam.
I haven't understood the solution.
Can anybody help me?Anita, have you resolved?
Thank you
Giulietta Blumarine
Ranch Hand

Joined: Dec 03, 2004
Posts: 59
I have modified my web.xml following your indications:

<init-param>
<param-name >convertNull </param-name >
<param-value >true </param-value >
</init-param >

OK, the text form value is not converted to zero but to null.
But If I insert in the form a character, for example, can I have a message type "int required"???

Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts Validator-Validating an Integer Form Field