XmlIDREF无法正常工作

时间:2014-07-18 11:07:18

标签: jaxb

使用JAXB 2.2.5b,并且

@XmlSeeAlso({BeanView.class, ViewField.class, ViewPanel.class, ViewTab.class, ElementRef.class})
@XmlRootElement
public abstract class ViewElement {
   @XmlID
   @XmlAttribute
   public String getId() {      
        return id;
   }
}
@XmlRootElement(name="ref")
public class ElementRef extends ViewElement{        
    private ViewElement target;
    @XmlElement
    @XmlIDREF
    public ViewElement getTarget() {
        return target;
    }   
    public void setTarget(ViewElement target) {
        this.target = target;
    }
}

许多类扩展了抽象的ViewElement

@XmlRootElement
public class ViewField extends ViewElement{
}
@XmlRootElement
public class ViewPanel extends ViewElement{
}

在XML中重复ElementRef目标元素,而不是仅保留id ref

<ref id="mvmCredit" >
    <target xsi:type="viewField" valueExpr="" row="0" ... all ViewField attributes >
    </target>
</ref>

并且在取消XML模型的过程中,目标为空(恢复失败)

1 个答案:

答案 0 :(得分:0)

升级到JAXB 2.2.7修复了问题