commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nise <dhar_nish...@yahoo.com>
Subject BeanUtils Not working !!!
Date Mon, 14 Jul 2008 04:57:08 GMT

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

when i run the code .. it just prints out

john
null

instead of

john
john

which i was expecting


wht cd i be doing wrong

thanks

nise


import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.logging.LogFactory;

class A{

String name;

public String getName()
{

return name;

}

public void setName(String name)
{
this.name= name;
}


}

class B
{

String name;

public String getName()
{

return name;

}

public void setName(String name)
{
this.name= name;
}


}




public class test {

public static void main(String args[])
{

A a1= new A();
B b1= new B();

a1.setName("John");
System.out.println(a1.getName());
try{
BeanUtils.copyProperties(b1,a1);
System.out.println(b1.getName());
}
catch(Exception e){}

}




} 
-- 
View this message in context: http://www.nabble.com/BeanUtils-Not-working-%21%21%21-tp18437474p18437474.html
Sent from the Commons - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message