You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Xuemin Guan <xu...@bbx-japan.com> on 2004/03/24 04:29:44 UTC

Form's property, String or not?

Hi, dear all, very new to Struts. Just a simple question:

As a best practice of Struts,  should I declare formebeans'
properties all as String, or the "actual" type (such as BigDecimal,
int, float, and double etc.)

Thanks,

Xuemin


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


Re: Form's property, String or not?

Posted by Xuemin Guan <xu...@bbx-japan.com>.
Thanks, Andrew, it explains very well.

Xuemin

----- Original Message ----- 
From: "Andrew Hill" <an...@gridnode.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Wednesday, March 24, 2004 12:33 PM
Subject: RE: Form's property, String or not?


> For actionforms you should make them all strings. Certainly anything that
> allows for text entry in the UI should be made a string even if it is
> intended for numeric input. (For checkboxes and such like its less
important
> though Id still recommend using strings for them)
>
> This allows you to return the user to the form when validation fails with
> the input they entered preserved - so if they type "One" instead of "1"
the
> bad value will be preserved for them to correct on return to the page.
>
> If they type text into a field whose actionform property is numeric you
can
> have problems handling it. I cant remember if it causes an exception or is
> just converted implicitly to the value 0 - but either way its a problem...
>
> -----Original Message-----
> From: Xuemin Guan [mailto:xuemin.guan@bbx-japan.com]
> Sent: Wednesday, 24 March 2004 11:30
> To: Struts Users Mailing List
> Subject: Form's property, String or not?
>
>
> Hi, dear all, very new to Struts. Just a simple question:
>
> As a best practice of Struts,  should I declare formebeans'
> properties all as String, or the "actual" type (such as BigDecimal,
> int, float, and double etc.)
>
> Thanks,
>
> Xuemin
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>


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


RE: Form's property, String or not?

Posted by Andrew Hill <an...@gridnode.com>.
For actionforms you should make them all strings. Certainly anything that
allows for text entry in the UI should be made a string even if it is
intended for numeric input. (For checkboxes and such like its less important
though Id still recommend using strings for them)

This allows you to return the user to the form when validation fails with
the input they entered preserved - so if they type "One" instead of "1" the
bad value will be preserved for them to correct on return to the page.

If they type text into a field whose actionform property is numeric you can
have problems handling it. I cant remember if it causes an exception or is
just converted implicitly to the value 0 - but either way its a problem...

-----Original Message-----
From: Xuemin Guan [mailto:xuemin.guan@bbx-japan.com]
Sent: Wednesday, 24 March 2004 11:30
To: Struts Users Mailing List
Subject: Form's property, String or not?


Hi, dear all, very new to Struts. Just a simple question:

As a best practice of Struts,  should I declare formebeans'
properties all as String, or the "actual" type (such as BigDecimal,
int, float, and double etc.)

Thanks,

Xuemin


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



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