The PropertyUtils.copyProperties() method does *not* perform any type conversions -- it expects the types to match already. However, BeanUtils.copyProperties() will apply the appropriate converters that have been registered in ConvertUtils for you. That makes it more useful for copying data to a DTO (which uses native data types) from a form bean (which typically uses Strings).
Craig On Tue, 17 Aug 2004 05:28:10 -0700 (PDT), Robert Bowen <[EMAIL PROTECTED]> wrote: > Hello. I am using Torque to generate the persistent > classes for my web application. Torque generates these > classes based on an xml file, in which you specify the > table name, column name and column type. > > What I would like to do is use copyProperties() to > copy from an ActionForm directly to my > Torque-generated beans but of course, everything is a > String in the ActionForm world, whereas in my > persistence classes my date fields, for example, are > Dates, not Strings, so copyProperties fails. > > I have been looking all over the jakarta web site, the > archives of this mailing list, etc. People seem to be > talking about creating a bean that acts as a > go-between, a DTO I suppose, that has the same fields, > getters and setters as the ActionForm, and that you > first copy the properties to the DTO. > > But ... won't I have the same problem when trying to > use copyProperties? Do I have to somehow use the > ConvertUtils instead? > > Any help much appreciated. I am using a single servlet > to instantiate a bean of type 'x', copy the values > from a form and save it in the database, so having to > type 'gets' and 'sets' for every possible case ... is > a waste of time, bad design, etc. > > Many thanks! > syg > > __________________________________ > Do you Yahoo!? > Yahoo! Mail is new and improved - Check it out! > http://promotions.yahoo.com/new_mail > > --------------------------------------------------------------------- > 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]
