On Thu, 31 Oct 2002, Andrew Hill wrote:

> Date: Thu, 31 Oct 2002 20:16:34 +0800
> From: Andrew Hill <[EMAIL PROTECTED]>
> Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>,
>      [EMAIL PROTECTED]
> To: Struts Users Mailing List <[EMAIL PROTECTED]>
> Subject: RE: MVC Design: property in ActionForm or Bean with property in
>     A ctionForm ?
>
> What is a 'good-practice' method of validating a numeric string?
> Ive been lazy and am doing a Integer.parseInt() in a try catch but its
> probably far from the best way...

Nothing wrong with that (in the validate() method, for example), given
that you're ultimately going to need to convert to an integer to use in
your model tier.  From a performance perspective, you might consider
keeping the converted value and making it available (to your Action) under
a different property name in order to avoid doing the conversion again.

> (Have been meaning to check out the java.text.NumberFormat stuff but always
> had more interes... uh... important things to do first and havent had time
> yet...)

But necessary if you want to allow your user to stick commas and decimal
points (or the reverse for countries that do it backwards :-) in a
Locale-sensitive manner.

Craig


--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@;jakarta.apache.org>

Reply via email to