struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craig McClanahan <craig...@gmail.com>
Subject Re: Issues keeping specifc data type in ActionForm instead of string
Date Tue, 01 Mar 2005 08:16:14 GMT
This can be illustrated fairly simply with a test application that:

* Declares a form bean property as an "int".

* Includes an <html:text> field bound to this form bean property.

* Has a user that types "1a3" instead of "123".

The problem is that users will expect the application to respond with
an error message, plus "1a3" in the text field so that his or her
previous response can be corrected, without having to be completely
replaced.  That is why Struts encourages you to use String properties
in form beans, and perform conversions (typically as a side effect of
callihng BeanUtils.setProperties()) after validations have succeeded,
so you know there won't be problems like this.

Craig McClanahan

PS:  Of course, if you were using UI component frameworks like
JavaServer Faces (in addition to or instead of Struts), you would not
encounter this difficulty -- the components themselves take
responsibility for reproducing the incorrect input in an error case.

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


Mime
View raw message