commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@daimlerchrysler.com
Subject [beanutils] copyProperties from Boolean to boolean
Date Thu, 22 Jul 2004 18:30:14 GMT
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();
        }
}

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message