commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tim O'Brien" <tobr...@discursive.com>
Subject RE: [betwixt] Collection property question
Date Thu, 13 Jan 2005 19:14:37 GMT
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
tobrien@discursive.com

-----Original Message-----
From: Matt Goodwin [mailto:mgoodwin@metalexis.com]
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
mgoodwin@metalexis.com
(515)708-0114
Metalexis
"Transcending the Ordinary"


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org






Mime
View raw message