Andreas Solarik wrote:

Hi Stjepan,

From what I understand, you will have a much easier time implementing
validation for your forms if you use only strings. For example, receiving an
integer value "ABCDEFG" might cause unexpected results.
This is just my understanding. If theres more to it, them I'm happy to learn
:)

That is my understanding too.


A simple example:

Imagine your form models a personnel record.

You have a field to hold an employee's Age. Being a clever Struts designer you add a String (not an Integer) property to the Struts form bean to hold the employee's Age.

You have Struts Validation enabled.

If someone types "QWERTY" into that Age field on the HTML form, your Struts validation checks can trap it and the form will be forwarded back to the user with (perhaps) the Age field showing "QWERTY", highlighted with a "QWERTY is not a valid Age" error message.

But: if that property had been modeled originally as an Integer, then "QWERTY" would never make it into the form bean (because "QWERTY" cannot be converted to an Integer). Which in turn means that when the form is re-displayed to show the user's error, the string "QWERTY" will not be seen in the Age field; the field would be empty.

Read-write Integer properties on form beans will work great until users enter bad data. Read-only properties are unaffected of course.

I think I got that about right.

--
bOOyah


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to