xml-xmlbeans-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mike Perham" <Mike.Per...@webifysolutions.com>
Subject RE: XmlValueNotNillableException
Date Wed, 28 Jul 2004 12:56:29 GMT
Kevin, I don't understand that decision.  If something is optional, it
seems like you should be able to set the cooresponding javabean property
to null.  We all have code that looks like this to copy to/from
different beans.

a1.setFoo(a2.getFoo());
a1.setBar(a2.getBar());
a1.setBaz(a2.getBaz());

What's the issue with supporting code inside each setter which does the
equivalent of: "if (value == null && usage == optional) return;" (that
is, make the set a no-op)?


-----Original Message-----
From: Kevin Krouse [mailto:kkrouse@bea.com] 
Sent: Tuesday, July 27, 2004 2:04 PM
To: xmlbeans-user@xml.apache.org
Subject: RE: XmlValueNotNillableException

Yes, you should check for null before setting it.  Setting a value of
null is equivalent to having xsi:nil="true" on the element.

________________________________

From: MIDON ALEXIS [mailto:ALEXIS.MIDON@sgam.com]
Sent: Tuesday, July 27, 2004 9:53 AM
To: 'xmlbeans-user@xml.apache.org'
Subject: XmlValueNotNillableException


 
Hello,
 
my schema defines an AddressInfo element. All the sub elements
(streetname, cityname, etc.) are optional.
 
I map this element with an AddressDTO as shown in the following code :
 
 
public static AddressInfo createAddress(AddressDTO dto) {
      AddressInfo address = AddressInfo.Factory.newInstance();

 
      address.setStreetName(dto.getAddress());
      address.setCityName(dto.getCity());
      address.setPostalCode(dto.getZipCode());

      return address;
 }
 
To that point I make no assumptions on the dto field value, ie the
getters could return null (this is the reason why tags are optional)
 
Unfortunately this code throws an unknown (i didn't find out any
javadocs) and unchecked exception :
org.apache.xmlbeans.impl.values.XmlValueNotNillableException
 
My biz fails due to this exception. :(
 
Is it a bug? a bad practice? Did I miss something?
 
Should I test every nullable value before setting the XMLObject ?
 
ex :
      if(dto.getAddress()!=null)
            address.setStreetName(dto.getAddress());
      if(dto.getCityName()!=null)
          address.setCityName(dto.getCity());
      if(dto.getPostalCode()!=null)
          address.setPostalCode(dto.getZipCode());
 
 
 
Thx for your help.
 
 
Alexis

- ---------------------------------------------------------------------
To unsubscribe, e-mail:   xmlbeans-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-user-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/



- ---------------------------------------------------------------------
To unsubscribe, e-mail:   xmlbeans-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-user-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/


Mime
View raw message