AW: Field types in ActionForm/DynaForm

2004-04-07 Thread Andreas Solarik
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
:)

Andreas

-Ursprngliche Nachricht-
Von: James Mitchell [mailto:[EMAIL PROTECTED]
Gesendet: Mittwoch, 07. April 2004 15:34
An: Struts Developers List
Cc: Struts Users Mailing List
Betreff: Re: Field types in ActionForm/DynaForm


This needs to be on [EMAIL PROTECTED]


--
James Mitchell
Software Engineer / Open Source Evangelist
EdgeTech, Inc.
678.910.8017
AIM: jmitchtx
MSN: [EMAIL PROTECTED]
Yahoo IM:[EMAIL PROTECTED]



- Original Message -
From: Stjepan Brbot [EMAIL PROTECTED]
To: STRUTS - Developer [EMAIL PROTECTED]
Sent: Wednesday, April 07, 2004 9:31 AM
Subject: Field types in ActionForm/DynaForm


 Hi all,

 Does STRUTS ActionForm/DynaForm have to consist only of String object
 fields!? Although I saw this strong recommendation in some books and
 articles on Internet (since all parameters in Request are Strings) I use
 Action and DynaForms with java.lang.Integer fields and everything works
 fine! (Integer fields are very convenient when one deals with EJBs where
IDs
 are of Integer type.) It seems that STRUTS framework automatically
converts
 Strings from request into defined fields types of Form. Why should one use
 only String fields and avoid Form fields other than Strings?

 Stjepan Brbot


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




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


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



Re: AW: Field types in ActionForm/DynaForm

2004-04-07 Thread bOOyah
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]