You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by bb...@daimlerchrysler.com on 2004/07/22 20:30:14 UTC
[beanutils] copyProperties from Boolean to boolean
Hi all,
My apologies if this is covered somewhere, I was unable to find anything
on google.
I have two beans with similar signatures, one with a primitive type
(boolean) and the other with the wrapper class (Boolean). When the
Boolean is set to null and I use copyProperties, I get a
NullPointerException. Is this known behaviour, a bug, something else?
Specifically i'm using struts and copying a form bean to a backend class.
I'll append a test case that demos the problem (Bean1 has the Boolean and
Bean2 the boolean).
Thanks in Advance,
Brian
import org.apache.commons.beanutils.PropertyUtils;
public class PropTest
{
public PropTest()
{
Bean1 bean1 = new Bean1();
bean1.setFlag(null);
Bean2 bean2 = new Bean2();
bean2.setFlag(false);
try {
PropertyUtils.copyProperties(bean2, bean1);
} catch (Exception e) {
e.printStackTrace(System.err);
}
}
public static void main(String args[]) {
PropTest pt = new PropTest();
}
}