When you read or write the bean using Betwixt, try
writer.getXMLIntrospector().getConfiguration().setWrapCollectionsInElement(false);
or
reader.getXMLIntrospector().getConfiguration().setWrapCollectionsInElement(false);
where writer or reader is your BeanWriter or BeanReader.
Tim O'Brien
[EMAIL PROTECTED]
-----Original Message-----
From: Matt Goodwin [mailto:[EMAIL PROTECTED]
Sent: Thu 1/13/2005 11:01 AM
To: Jakarta Commons Users List
Subject: [betwixt] Collection property question
I have xml I need to map to my bean. It is very similar to the
CustomerBean example, except I am using Collection instead of and array
of objects (i.e. Order[]). Here is a sample of the xml, followed by my
class, followed by my .betwixt file. The problem I am having is the
List is always null. How do you map objects in the .betwixt file if the
collection has no surrounding element tag (i.e.
<orders></order></order></orders>)?
Example xml:
<AgentStatementVO>
<StatementDate>2004/10/08</StatementDate>
<AgentInfoVO>...</AgentInfoVO>
<AgentStatementLineVO>...</AgentStatementLineVO>
<AgentStatementLineVO>...</AgentStatementLineVO>
<AgentEarningsVO>...</AgentEarningsVO>
</AgentStatementVO>
Class:
public class AgentStatement implements java.io.Serializable {
private Date statementDate;
private AgentInfo agentInfo;
private Collection agentStatementDetails = new java.util.ArrayList();
private AgentEarning agentEarning;
/* .. snip non-relevant getters/setters */
public Collection getAgentStatementDetails() {
return agentStatementDetails;
}
public void setAgentStatementDetails(Collection agentStatementDetails) {
this.agentStatementDetails = agentStatementDetails;
}
public void addAgentStatementDetail(AgentStatementDetail
agentStatementDetail) {
this.agentStatementDetails.add(agentStatementDetail);
}
}
Betwixt file:
<?xml version='1.0' ?>
<info>
<element name='AgentStatementVO'>
<element name='StatementDate' property='statementDate'/>
<element name='AgentInfoVO' property='agentInfo'/>
<element name='AgentStatementLineVO'
property='agentStatementDetails'
class='com.equitrust.commissionloader.beans.AgentStatementDetail'/>
<element name='AgentEarningsVO' property='agentEarning'/>
</element>
</info>
Everything except the agentStatementDetails are populated correctly.
Thanks,
Matt
--
Matt Goodwin
[EMAIL PROTECTED]
(515)708-0114
Metalexis
"Transcending the Ordinary"
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]