users@jaxb.java.net

Re: XJC error message -> extends SingleField

From: <HeruMartinus.Salim_at_infineon.com>
Date: Thu, 16 Nov 2006 13:28:49 +0100

Sorry, I have mispressed the button (last email not fully typed, and
accidentally pressed the sent shortcut)

> > > After that I tried to extend the class SingleClass.
> > > Here I added the enum of Messages hard-coded into this class.
> > >
> > > And still while parsing xml schema I got an error message
> > >
> > > C:\UserData\salimher\testJava\plugin\build.xml:42:
> > > java.lang.IllegalArgumentException: trying to create the
> same field
> > > twice: addressUnit
> >
> > Obviously you're trying to create the same field within the defined
> > class twice.
> > Review your field renderer code.
>
> The Problem, I didn't make any changes besides renaming the classname
> and identifier to fit the extending renderer
>

I think I've found the problem (just my guess),

   public MySingleField(ClassOutlineImpl context, CPropertyInfo prop) {
        this(context,prop,false);
    }

    /**
     *
     * @param forcePrimitiveAccess
     * forces the setter/getter to expose the primitive type.
     * it's a pointless customization, but it's nevertheless in the
spec.
     */
    public MySingleField(ClassOutlineImpl context, CPropertyInfo prop,
boolean forcePrimitiveAccess ) {
        super(context, prop);
        assert !exposedType.isPrimitive() && !implType.isPrimitive();
        
        System.out.println("Prop: " + prop.getName() + " " +
prop.displayName());
        createField();
        .....
    }

From the constructor of SingleField, there is a statement call super()
which in turn call the constructor of AbstractFieldWithVar (superclass
of SingleField).
The problem is when I extend the SingleField class into MySingleField
class, the superclass is now the SingleField. So it calls the
2-parameter constructor of super class (SingleField), and then later
called the costructor of the 3-parameter constructor of SingleField.
So it calls the "createField" method twice (once from the SingleField,
second from the MySingleField)

I tried to extend also the AbstractFieldWithVar, but met the same
problem, so I extend also the AbstractField, but this time, failed,
while AbstractField is not accessible from outside class.

Is there any solution for this?
Can somebody give some examples about extending this
FieldRendererFactory???

Thanks.
Regards,
Heru