You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mike Dewhirst <De...@UCLES.org.uk> on 2001/08/15 11:42:25 UTC

form validation

How is it possible to validate input in struts for formatting?

What I mean is, is it possible to check when a string is entered into an
input field that populates an int? It seems that the Controller populates
the int with a 0, which makes it difficult to detect if this was an invalid
input, or a "real" 0.

Would we need to extend the framework if we want to be able to detect this?

Thanks for any advice!!


=**********************************************************

If you are not the intended recipient, employee or agent responsible for delivering the message to the intended recipient, you are hereby notified that any dissemination or copying of this communication and its attachments is strictly prohibited.

If you have received this communication and its attachments in error, please return the original message and attachments to the sender using the reply facility on e-mail.

Internet communications are not secure and therefore the UCLES Group does not accept legal responsibility for the contents of this message.  Any views or opinions presented are solely those of the author and do not necessarily represent those of the UCLES Group unless otherwise specifically stated.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses although this does not guarantee that this email is virus free.

**********************************************************=

Re: form validation

Posted by Gregor Rayman <gr...@gmx.net>.
"Mike Dewhirst" <De...@UCLES.org.uk>



> How is it possible to validate input in struts for formatting?
> 
> What I mean is, is it possible to check when a string is entered into an
> input field that populates an int? It seems that the Controller populates
> the int with a 0, which makes it difficult to detect if this was an invalid
> input, or a "real" 0.
> 
> Would we need to extend the framework if we want to be able to detect this?
> 
> Thanks for any advice!!

You can either use String (in this way you can accept inputs like "2.001"),
or you can use Integer. It will be null, if no correct integer is has been 
entered.

--
gR


Re: form validation

Posted by Will Jaynes <wj...@mediaone.net>.
Many developers recommend that the ActionForm properties all be String, so that
validation can be done on just what the user typed, and so that any error
messages can display to the user exactly what s/he typed. Yes, the controller
can do conversions for you, but I never use that feature.

Will

----- Original Message -----
From: "Mike Dewhirst" <De...@UCLES.org.uk>
To: <st...@jakarta.apache.org>
Sent: Wednesday, August 15, 2001 5:42 AM
Subject: form validation


How is it possible to validate input in struts for formatting?

What I mean is, is it possible to check when a string is entered into an
input field that populates an int? It seems that the Controller populates
the int with a 0, which makes it difficult to detect if this was an invalid
input, or a "real" 0.

Would we need to extend the framework if we want to be able to detect this?

Thanks for any advice!!