Wrapper element splitted in different list

View: New views
2 Messages — Rating Filter:   Alert me  

Wrapper element splitted in different list

by Michenux :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I have a list :
<bean>
<wrapper>
   <elemA>value1</elemA>
   <elemA>value2</elemA>
   <elemB>word1</elemB>
   <elemB>word2</elemB>
   <elemB>word3</elemB>
</wrapper>
</bean>

I want to map to a different list for each kind of elements, so i did :

public class Bean {

@XmlElementWrapper(name="wrapper")
@XmlElement(name="elemA")
private List listA ;

@XmlElementWrapper(name="wrapper")
@XmlElement(name="elemB")
private List listB ;
}

My problem is that only the listA is populated and listB is null.
If i comment the field listA in the bean, the listB is well populated.

So, i think i'm doing wrong or maybe it is not possible.

Thanks for helping.


Re: Wrapper element splitted in different list

by Wolfgang Laun-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

You are not showing or describing how <a> and <b> occur within <wrapper>. If they occur in any (mixed) order, you won't be able to separate them into two lists since this would not reflect the order in which these elements occur in the XML document. This list will then be List<JAXBElement<?>> and can be processed easily by looking at the "name" property of JAXBElement.

If all <a> elements precede (or follow) all <b>, then declare another class for <wrapper> with lists for <a> and <b>.

--W

On Sat, Oct 31, 2009 at 5:22 PM, Michenux <lmichenaud@...> wrote:

Hi,

I have a list :
<bean>
<wrapper>





</wrapper>
</bean>

I want to map to a different list for each kind of elements, so i did :

public class Bean {

@XmlElementWrapper(name="wrapper")
@XmlElement(name="a")
private List  listA ;

@XmlElementWrapper(name="wrapper")
@XmlElement(name="b")
private List listB ;
}

My problem is that only the listA is populated and listB is null.
If i comment the field listA in the bean, the listB is well populated.

So, i think i'm doing wrong or maybe it is not possible.

Thanks for helping.


--
View this message in context: http://old.nabble.com/Wrapper-element-splitted-in-different-list-tp26143797p26143797.html
Sent from the java.net - jaxb users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...