[prev in list] [next in list] [prev in thread] [next in thread] 

List:       struts-user
Subject:    RE: MVC Design: property in ActionForm or Bean with property in A
From:       "Craig R. McClanahan" <craigmcc () apache ! org>
Date:       2002-10-31 17:16:39
[Download RAW message or body]



On Thu, 31 Oct 2002, Andrew Hill wrote:

> Date: Thu, 31 Oct 2002 20:16:34 +0800
> From: Andrew Hill <andrew.david.hill@gridnode.com>
> Reply-To: Struts Users Mailing List <struts-user@jakarta.apache.org>,
>      andrew.david.hill@gridnode.com
> To: Struts Users Mailing List <struts-user@jakarta.apache.org>
> 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>

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic