Name:
Location: Bangalore, India

Saturday, September 22, 2007

Copying the data (properties) from one object to object.


BeanUtils.copyProperties(Destination, Source);

import org.apache.commons.beanutils.BeanUtils;

We need to have the following jar file in place for this function to work.

commons-beanutils.jar

BeanUtils.copyProperties(objRequestForm, objRequestDTO);

For this "the source and destination" property name and datatype should match like,

RequestForm:
String name;
int empNumber;

RequestDTO:
String name;
int empNumber;

As you can see above the property names as well as datatypes are alike.

0 Comments:

Post a Comment

<< Home