2014-03-06 20 views
1

我有一個textfield對象,我標記不映射到使用XmlTransient。
當我創建文本字段對象並將字符串傳遞給它時。文本字段認爲該字符串爲空。我的問題是,我傳入文本字段的字符串是先映射還是在我的瞬態對象之後發生?什麼時候使用Jaxb初始化數據?

public class INDEX { 
    @XmlTransient  
    public TextField contenttext = new TextField(getContent()); 
    private String content;  
    private Map<QName,String> attributes = new HashMap<QName,String>();  

    public String getContent() {  
     return content;  
    } 
    @XmlValue  
    public void setContent(String content) {  
     this.content = content;  
    } 

    public Map<QName,String> getAttributes() {  
     return attributes;  
    }  
    @XmlAnyAttribute  
    public void setAttributes(Map<QName,String> attributes) {  
     this.attributes = attributes;  
    }  
} 

回答

0

contenttext場將要使用的TextField實例儘快類屬於(INDEX)被實例化填充。此時content屬性爲null。然後,一旦實例化類,JAXB將從解組操作中填充映射字段和屬性的值。

相關問題