Another big issue is that the ActionForm primarily deals in strings (since its populated from the request parameters) while the value objects will be using datatypes appropriate to the property in question.
While the form population can convert as needed this is only fine for the happy scenario where the user enters valid data. For the unhappy scenario it becomes very messy very quickly. Its best to populate a string property in the actionform and then validate it. If invalid one redisplays the screen with whatever garbage the user typed in (and an error message) and allows them to correct it. If one tried to convert directly and store straight into a value object one would find all sorts of problems like a value of "blah" for an int property being stored as a 0... Another issue is that over time as the application is developed the properties for by the ui, and the properties for the business layer start to diverge significantly, so you end up will all sorts of messy compromises in your value objects... Keeping the data entry buffer (actionform) seperate from the value object helps prevent such problems. -----Original Message----- From: Kalra, Ashwani [mailto:[EMAIL PROTECTED] Sent: Friday, 1 August 2003 13:27 To: 'Struts Users Mailing List' Subject: RE: Direct ValueObject creation rather than ActionForm. One drawback. ActionForm classes import classes from http packages. which binds it to the particular layer. Cheers Ashwani Kalra http://www.geocities.com/ashwani_kalra/ > -----Original Message----- > From: Andrew Hill [mailto:[EMAIL PROTECTED] > Sent: Friday, August 01, 2003 10:47 AM > To: Struts Users Mailing List > Subject: RE: Direct ValueObject creation rather than ActionForm. > > > This is quite a common idea that many people new to struts > have. There are > quite a few reasons why your ActionForm and your value object > are different > objects. (Indeed the very reason ActionForm is implemented as > a class rather > than an interface is specifically to discourage people from > using their > ActionForm as a value object.) If you search the list > archives you will see > numerous threads discussing the reasons why this is in fact a > very bad idea > indeed. > -----Original Message----- > From: Viral_Thakkar [mailto:[EMAIL PROTECTED] > Sent: Friday, 1 August 2003 13:05 > To: [EMAIL PROTECTED] > Subject: Direct ValueObject creation rather than ActionForm. > > > I have a idea here. Why we require ActionForm class if we can have > ValueObject and that we can pass to the service layer. > > > > Can we create the instance of ValueObject class only rather than > ActionForm instance from the request data? > > > > Thanks > > > > > > ____________________________________________________ This message contains information that may be privileged or confidential and is the property of the Cap Gemini Ernst & Young Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorised to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. --------------------------------------------------------------------- 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]