Joe,
Yeah thats exactly it,
for example we have something like:
<xs:complexType name="Customer">
<xs:sequence>
<xs:element name="userID" type="xs:string" default="fred" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
customer.getUserID() does not return "fred".
Looking at the JAXB generated class (Customer) I expected to see:
protected java.lang.String _userID = "fred";
but this was not the case. We are not using object factory to create the bean (we are just constructing it as new Customer(), could this be a problem?
Element defaults in the generated XML could be useful too, but the priority is the attribute defaults in the java code.
thanks in advance,
Tim.
-----Original Message-----
From: Joe Fialli [mailto:Joseph.Fialli_at_Sun.COM]
Sent: Friday, June 06, 2003 5:09 PM
To: JAXB-INTEREST_at_JAVA.SUN.COM
Subject: Re: Jaxb 1.0.1 and defaults values
Tim Davidson wrote:
>hello people,
>
> I managed to get jaxb 1.0.1 working with my schmas, but it still doesn't appear to be picking up default values from the schma. We are using the jaxb generated classes as a bean on a web site and we require defaults. Is this still a bug? or are the defaults for the generated xml only and not the class itself? can you reccommend a fix?
>
Are you inquiring what happens to a JAXB property that is related to an
XML Schema attribute with a default value?
Lets use the following explicit example that I am assuming summarizes
your situation:
XML Schema fragrment <xs:attribute name="Foo" type="xsd:string"
default="default value"/>
Java Fragrment:
XXX x = (XXX)ObjectFactory.createXXX()
x.getFoo() should return "default value" and you are seeing "" instead.
Additionally, were you looking for element defaulting as well as
attribute defaulting.
-Joe Fialli, Sun Microsystems
>
>regards
>
>
>