On Thu, 27 Feb 2003, Damm, Gary wrote:
> Date: Thu, 27 Feb 2003 08:53:11 -0800 > From: "Damm, Gary" <[EMAIL PROTECTED]> > Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]> > To: Struts Users Mailing List <[EMAIL PROTECTED]> > Subject: RE: Search example of BeanUtilities.copyProperties with a form > that display table > > Here is how I understand the BeanUtil.copyProperies. > > 1. It expects that the src and dest beans have the same member names to > be copied. (In your case the customer bean would have id,name,country > and select) members. > More precisely, it only takes action when there are matching property names. Either the source bean or the destination bean can have additional properties, which BeanUtils.copyProperties() will ignore. > 2. It expects these members to have getter and setter methods. > True for non-DynaBean beans. However, if the source or destination is a DynaBean (which includes DynaActionForm and DynaValidatorActionForm), then BeanUtils knows this and uses the get() and set() methods of the DynaBean interface correctly. > 3. The data type is converted based on rules defined in the > commons-beanutils package, so they do not have to be the same data type > in most cases as long as there is an applicable conversion rule. And you can customize conversions for nonstandard cases. > > I don't believe it will copy a bean (in your case the DynaValidatorForm) > into a Collection. You will need to copy from form to business tier > bean then add that bean to your Collection (in your case copy the form > to a Customer object then add the object to your Collection). > It would be straightforward to create and register a Converter for Collection that would deal with this. See the BeanUtils Javadocs for more information: http://jakarta.apache.org/commons/beanutils/api/ > Hope this helps, > Gary > Craig > -----Original Message----- > From: Heligon Sandra [mailto:[EMAIL PROTECTED] > Sent: Thursday, February 27, 2003 8:43 AM > To: '[EMAIL PROTECTED]' > Subject: Search example of BeanUtilities.copyProperties with a form that > display table > Importance: High > > > I have a JSP that contains a table of customers for example. > > Through the business Tier I have retrieved an object Customers > that > is a Collection > of Customer object. > > I have defined a DynValidatorForm: > > <form-bean name="customersForm" dynamic="true" > type="org.apache.struts.validator.DynaValidatorForm"> > <form-property name="id" type="java.lang.String[]"/> > <form-property name="name" type="java.lang.String[]"/> > <form-property name="country" type="java.lang.String[]"/> > <form-property name="select" type="java.lang.String[]"/> > </form-bean> > > To populate the form from the business data can I do directly: > BeanUtilities.copyProperties(customersForm, Customers); > > To populate the business data from the form can I do directly: > BeanUtilities.copyProperties(Customers, customersForm); > > These two lines imply that the form and the business data have > exactly the same > properties, isn't it ? > > The information about the last column (select or not) is saved > in > the > HttpSession how must I do to update this property ? > > Is it possible that a form is the combination of multiple > Business > data collections ? > how to make in this case ? > Must one define two different forms ? and use the two forms in > the > same JSP ? > I found only one example that uses BeanUtilities.copyProperties > (http://drdb.fsa.ulaval.ca/sujets/struts/membership03/index.html) > but this example doesn't display any collection only one record. > If > someone has an other example I am > very very interested. > Thanks a lot in advance > > > > ----------------------------------------------------------- > As of February 12, 2003 Thomson unifies its email addresses on a > worldwide > basis.Please note my new email address: [EMAIL PROTECTED] > > Thomson is the leader in solutions and technologies for the > entertainment > and media industries and serves its customers under its four strategic > brands: Technicolor, Grass Valley, RCA and THOMSON. > More about Thomson: http://www.thomson.net/videochain > > > --------------------------------------------------------------------- > 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]

