import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.logging.LogFactory;
Hi,
I am using BeanUtils for copying the contents of one bean into another using reflection.
The code is really simple and it compiles and runs fine but does not give the desired output.
It basically *DOES NOT* copy the property 'name' from the source to the destination bean
wht cd i be doing wrong
thanks
nise
class A{
int name;
public int getName()
{
return name;
}
public void setName(int name)
{
this.name= name;
}
}
class B
{
int name;
public int getName()
{
return name;
}
public void setName(int name)
{
this.name= name;
}
}
public class
test {
public static void main(
String args[])
{
A a1= new A();
B b1= new B();
a1.setName(1);
System.out.println(a1.getName());
try{
BeanUtils.copyProperties(b1,a1);
System.out.println(b1.getName());
}
catch(Exception e){}
}
}