Alright, I am new to JAXB and having trouble finding the correct documentation to help me through this, I have read a bunch and still dont understand what JaxB is doing.
I have a class, Call it Container. It is extended by MyContainer. MyContainer has an additional boolean value in addition to what it inherits from Container.
Anyways, this is how JAXB Marshalls MyContainer
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<MyContainer name="container" id="1">
<boolVal>false</boolVal>
<ListOfResources> //Using @XmlElementWrapper(name=..
<child>
<ID>Test Comp 1</ID>
</child>
<child>
<ID>Test Comp 2</ID>
</child>
</ListOfResources>
</MyContainer>
What I don't understand is the tag "child". The only thing named child is the name of the list. The list contains objects (Which have a string property, ID) however the object should not be "child" . The real issue however is when I go to Demarshall the class. The list will populate with the listed "childs". I dont see what I am missing. I don't get a JAXB exception, mind you, but I when I check the unmarshalled object the list is unpopulated
EDIT: Clarification
I am sorry, What I am saying is the JAXB will marshall the elements within the list, albeit each element in the list having the name of the list (child). When it goes to demarshall, however, it does not populate the list in the new object.
EDIT2: Current Setter
public void setChildren(List<Resource<IType>> other) {
Iterator iterator = other.iterator();
while(iterator.hasNext()){
Resource<IType> piece =
new Resource<IType>((Resource<IType>) iterator.next());
this.listOfResources.add(piece);
}
}
See Question&Answers more detail:os