users@jaxb.java.net

Re: XmlType.propOrder

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Tue, 02 Jan 2007 12:29:06 -0800

Jamie wrote:
> Kohsuke Kawaguchi wrote:
>> Jamie wrote:
>>> From what I can tell, this did not make it into 2.1. Can someone
>>> confirm, and is it still
>>> planned to be in there?
>>> Jamie wrote:
>>>> Can someone confirm that XmlType.propOrder for inherited attributes
>>>> does not work for the RI 2.0, but does for the newly released 2.1?
>>
>> Can you give us bit more details? I'm not sure what you mean by
>> inherited attributes.
>>
> Sorry, yeah, the problem I'm trying to solve is that I have a base class
> which is a descriptor, it has a few attributes: name, label, key
> I have many different subclasses of the descriptor, some of which don't
> really add any attributes that I care about, some add an order
> attribute, and some add the order and/or other attributes.
>
> So I was hoping I could annotate my OrderedDescriptor class thusly (with
> name, label and key coming from the base class):
>
> @XmlType(propOrder={"name", "label", "order", "key"})
> public class OrderedDescriptor extends Descriptor {
> @XmlElement(name="order")
> public int getOrder() {
> return myOrder;
> }
> }
>
> I found some threads in JAXB discussions that stated this is not
> possible in JAXB 2.0, but that it was highly desired (without having to
> mark the name, label, key attributes in the base class as transient and
> have to override them in the subclasses, making alot of extra methods
> which simply call the super method)... I think you actually said it was
> scheduled for 2.1 (these were discussions from july 2006), so I checked
> out 2.1 but it doesn't look like it made it in.

I think this is in 2.1. You'd just need to put @XmlTransient on the
Descriptor class to do it.




-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com