You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Galbreath, Mark" <Ga...@tessco.com> on 2002/10/31 13:12:34 UTC

RE: MVC Design: property in ActionForm or Bean with property in A ctionForm ?

Check out the static methods of the java.lang.Character class.  isDigit()
should solve your dilemma.

Mark

-----Original Message-----
From: Marcus Biel [mailto:Marcus.Biel@bmw.de]
Sent: Thursday, October 31, 2002 7:04 AM

yes of course I know!
But how can I be sure that this "String" is a "Integer" ?

I mean I can simply convert this String to an Integer,
but I doubt this would help, cause a String can get converted to an
Integer.
(Like A is 65 I think)

So how can I be sure that the user typed 65 and not A ?

Marcus


Galbreath@tessco.com schrieb:
> 
> Are you kidding?  Dude, everything typed in an HTML form is a string.  You
> have to do some validation.
> 
> Mark

--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: MVC Design: property in ActionForm or Bean with property in A ctionForm ?

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Thu, 31 Oct 2002, Andrew Hill wrote:

> Date: Thu, 31 Oct 2002 20:16:34 +0800
> From: Andrew Hill <an...@gridnode.com>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>,
>      andrew.david.hill@gridnode.com
> To: Struts Users Mailing List <st...@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:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: MVC Design: property in ActionForm or Bean with property in A ctionForm ?

Posted by Andrew Hill <an...@gridnode.com>.
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...
(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...)

-----Original Message-----
From: Galbreath, Mark [mailto:Galbreath@tessco.com]
Sent: Thursday, October 31, 2002 20:13
To: 'Struts Users Mailing List'
Subject: RE: MVC Design: property in ActionForm or Bean with property in
A ctionForm ?


Check out the static methods of the java.lang.Character class.  isDigit()
should solve your dilemma.

Mark

-----Original Message-----
From: Marcus Biel [mailto:Marcus.Biel@bmw.de]
Sent: Thursday, October 31, 2002 7:04 AM

yes of course I know!
But how can I be sure that this "String" is a "Integer" ?

I mean I can simply convert this String to an Integer,
but I doubt this would help, cause a String can get converted to an
Integer.
(Like A is 65 I think)

So how can I be sure that the user typed 65 and not A ?

Marcus


Galbreath@tessco.com schrieb:
>
> Are you kidding?  Dude, everything typed in an HTML form is a string.  You
> have to do some validation.
>
> Mark

--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>

--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>