You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Matt Goodwin <mg...@metalexis.com> on 2005/01/14 21:19:46 UTC
[digester] internal object not populated
Hi,
I am trying to simply populate an object from xml, but while some
properties on the object (statementDate - a String and
agentStatementDetails - an arraylist of AgentStatementDetail objects)
populate 2 others are not populated (agentInfo - an AgentInfo object and
agentEarning - an AgentEarning object).
I have the following code:
Digester digester = new Digester();
digester.setValidating(false);
digester.addObjectCreate("AgentStatementVO",AgentStatement.class);
digester.addBeanPropertySetter("AgentStatementVO/StatementDate","statementDate");
digester.addObjectCreate("AgentStatementVO/AgentInfoVO",AgentInfo.class);
digester.addBeanPropertySetter("AgentStatementVO/AgentInfoVO/FirstName","firstName");
digester.addBeanPropertySetter("AgentStatementVO/AgentInfoVO/Name","lastName");
digester.addBeanPropertySetter("AgentStatementVO/AgentInfoVO/AgentId","agentId");
digester.addBeanPropertySetter("AgentStatementVO/AgentInfoVO/Address1","address1");
digester.addBeanPropertySetter("AgentStatementVO/AgentInfoVO/Address2","address2");
digester.addBeanPropertySetter("AgentStatementVO/AgentInfoVO/City","city");
digester.addBeanPropertySetter("AgentStatementVO/AgentInfoVO/State","state");
digester.addBeanPropertySetter("AgentStatementVO/AgentInfoVO/Zip","zip");
digester.addBeanPropertySetter("AgentStatementVO/AgentInfoVO/AgentType","agentType");
digester.addBeanPropertySetter("AgentStatementVO/AgentInfoVO/DisbursementSource","disbursementSource");
digester.addObjectCreate("AgentStatementVO/AgentStatementLineVO",AgentStatementDetail.class);
digester.addBeanPropertySetter("AgentStatementVO/AgentStatementLineVO/AgentNumber","agentNumber");
digester.addBeanPropertySetter("AgentStatementVO/AgentStatementLineVO/ProductType","productType");
digester.addBeanPropertySetter("AgentStatementVO/AgentStatementLineVO/FirstName","firstName");
digester.addBeanPropertySetter("AgentStatementVO/AgentStatementLineVO/Name","lastName");
digester.addBeanPropertySetter("AgentStatementVO/AgentStatementLineVO/EffectiveDate","effectiveDate");
digester.addBeanPropertySetter("AgentStatementVO/AgentStatementLineVO/ProcessDate","processDate");
digester.addBeanPropertySetter("AgentStatementVO/AgentStatementLineVO/OwnerName","ownerName");
digester.addBeanPropertySetter("AgentStatementVO/AgentStatementLineVO/PolicyNumber","policyNumber");
digester.addBeanPropertySetter("AgentStatementVO/AgentStatementLineVO/InitialPremium","initialPremium");
digester.addBeanPropertySetter("AgentStatementVO/AgentStatementLineVO/CommissionRate","commissionRate");
digester.addBeanPropertySetter("AgentStatementVO/AgentStatementLineVO/CommissionPremium","commissionPremium");
digester.addBeanPropertySetter("AgentStatementVO/AgentStatementLineVO/Type","commissionType");
digester.addBeanPropertySetter("AgentStatementVO/AgentStatementLineVO/AmountDue","amountDue");
digester.addSetNext("AgentStatementVO/AgentStatementLineVO","addAgentStatementDetail","com.equitrust.commissionloader.beans.AgentStatementDetail");
digester.addObjectCreate("AgentStatementVO/AgentEarningsVO",AgentEarning.class);
digester.addBeanPropertySetter("AgentStatementVO/AgentEarningsVO/TaxableIncome","taxableIncome");
digester.addBeanPropertySetter("AgentStatementVO/AgentEarningsVO/TaxableIncomeYTD","taxableIncomeYTD");
digester.addBeanPropertySetter("AgentStatementVO/AgentEarningsVO/PositivePolicyEarnings","positiveEarnings");
digester.addBeanPropertySetter("AgentStatementVO/AgentEarningsVO/NegativePolicyEarnings","negativeEarnings");
digester.addBeanPropertySetter("AgentStatementVO/AgentEarningsVO/NetPolicyEarnings","netEarnings");
AgentStatement statement = (AgentStatement)digester.parse(xmlReader);
Does anyone see what would be causing this behavior.
I am using the following test xml.
<AgentStatementVO>
<StatementDate>2004/10/08</StatementDate>
<AgentInfoVO>
<FirstName/>
<Name>xxxx</Name>
<AgentId>xxxx</AgentId>
<Address1>xxxx</Address1>
<Address2>xxxx</Address2>
<City>xxxx</City>
<State>xx</State>
<Zip>xxxxx</Zip>
<AgentType>xxxx</AgentType>
<DisbursementSource>xxxx</DisbursementSource>
</AgentInfoVO>
<AgentStatementLineVO>
<AgentNumber>xxxx</AgentNumber>
<ProductType>xxxx</ProductType>
<FirstName>xxxx</FirstName>
<Name>xxxx</Name>
<EffectiveDate>2004/10/04</EffectiveDate>
<ProcessDate>2004/10/05</ProcessDate>
<OwnerName>xxxx</OwnerName>
<PolicyNumber>0</PolicyNumber>
<InitialPremium>0</InitialPremium>
<CommissionRate>0.0</CommissionRate>
<CommissionPremium>0</CommissionPremium>
<Type>xxxx</Type>
<AmountDue>0</AmountDue>
</AgentStatementLineVO>
<AgentEarningsVO>
<TaxableIncome>0.0</TaxableIncome>
<TaxableIncomeYTD>0.0</TaxableIncomeYTD>
<PositivePolicyEarnings>0</PositivePolicyEarnings>
<NegativePolicyEarnings>0</NegativePolicyEarnings>
<NetPolicyEarnings>0</NetPolicyEarnings>
</AgentEarningsVO>
</AgentStatementVO>
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
Re: [digester] internal object not populated
Posted by Matt Goodwin <mg...@metalexis.com>.
Sorry forgot, these are the objects.
public class AgentStatement implements java.io.Serializable {
private String statementDate;
private AgentInfo agentInfo;
//private Vector agentStatementDetailList = new Vector();
private ArrayList agentStatementDetails = new ArrayList();
private AgentEarning agentEarning;
}
public class AgentEarning implements java.io.Serializable {
private double positiveEarnings;
private double negativeEarnings;
private double netEarnings;
private double taxableIncome;
private double taxableIncomeYTD;
}
public class AgentInfo implements java.io.Serializable {
private String firstName;
private String lastName;
private String agentId;
private String address1;
private String address2;
private String city;
private String state;
private String zip;
private String agentType;
private String disbursementSource;
}
Matt Goodwin wrote:
> Hi,
> I am trying to simply populate an object from xml, but while some
> properties on the object (statementDate - a String and
> agentStatementDetails - an arraylist of AgentStatementDetail objects)
> populate 2 others are not populated (agentInfo - an AgentInfo object
> and agentEarning - an AgentEarning object).
> I have the following code:
> Digester digester = new Digester();
> digester.setValidating(false);
>
> digester.addObjectCreate("AgentStatementVO",AgentStatement.class);
> digester.addBeanPropertySetter("AgentStatementVO/StatementDate","statementDate");
>
> digester.addObjectCreate("AgentStatementVO/AgentInfoVO",AgentInfo.class);
> digester.addBeanPropertySetter("AgentStatementVO/AgentInfoVO/FirstName","firstName");
>
> digester.addBeanPropertySetter("AgentStatementVO/AgentInfoVO/Name","lastName");
>
> digester.addBeanPropertySetter("AgentStatementVO/AgentInfoVO/AgentId","agentId");
>
> digester.addBeanPropertySetter("AgentStatementVO/AgentInfoVO/Address1","address1");
>
> digester.addBeanPropertySetter("AgentStatementVO/AgentInfoVO/Address2","address2");
>
> digester.addBeanPropertySetter("AgentStatementVO/AgentInfoVO/City","city");
>
> digester.addBeanPropertySetter("AgentStatementVO/AgentInfoVO/State","state");
>
> digester.addBeanPropertySetter("AgentStatementVO/AgentInfoVO/Zip","zip");
> digester.addBeanPropertySetter("AgentStatementVO/AgentInfoVO/AgentType","agentType");
>
> digester.addBeanPropertySetter("AgentStatementVO/AgentInfoVO/DisbursementSource","disbursementSource");
>
> digester.addObjectCreate("AgentStatementVO/AgentStatementLineVO",AgentStatementDetail.class);
>
> digester.addBeanPropertySetter("AgentStatementVO/AgentStatementLineVO/AgentNumber","agentNumber");
>
> digester.addBeanPropertySetter("AgentStatementVO/AgentStatementLineVO/ProductType","productType");
>
> digester.addBeanPropertySetter("AgentStatementVO/AgentStatementLineVO/FirstName","firstName");
>
> digester.addBeanPropertySetter("AgentStatementVO/AgentStatementLineVO/Name","lastName");
>
> digester.addBeanPropertySetter("AgentStatementVO/AgentStatementLineVO/EffectiveDate","effectiveDate");
>
> digester.addBeanPropertySetter("AgentStatementVO/AgentStatementLineVO/ProcessDate","processDate");
>
> digester.addBeanPropertySetter("AgentStatementVO/AgentStatementLineVO/OwnerName","ownerName");
>
> digester.addBeanPropertySetter("AgentStatementVO/AgentStatementLineVO/PolicyNumber","policyNumber");
>
> digester.addBeanPropertySetter("AgentStatementVO/AgentStatementLineVO/InitialPremium","initialPremium");
>
> digester.addBeanPropertySetter("AgentStatementVO/AgentStatementLineVO/CommissionRate","commissionRate");
>
> digester.addBeanPropertySetter("AgentStatementVO/AgentStatementLineVO/CommissionPremium","commissionPremium");
>
> digester.addBeanPropertySetter("AgentStatementVO/AgentStatementLineVO/Type","commissionType");
>
> digester.addBeanPropertySetter("AgentStatementVO/AgentStatementLineVO/AmountDue","amountDue");
>
> digester.addSetNext("AgentStatementVO/AgentStatementLineVO","addAgentStatementDetail","com.equitrust.commissionloader.beans.AgentStatementDetail");
>
> digester.addObjectCreate("AgentStatementVO/AgentEarningsVO",AgentEarning.class);
>
> digester.addBeanPropertySetter("AgentStatementVO/AgentEarningsVO/TaxableIncome","taxableIncome");
>
> digester.addBeanPropertySetter("AgentStatementVO/AgentEarningsVO/TaxableIncomeYTD","taxableIncomeYTD");
>
> digester.addBeanPropertySetter("AgentStatementVO/AgentEarningsVO/PositivePolicyEarnings","positiveEarnings");
>
> digester.addBeanPropertySetter("AgentStatementVO/AgentEarningsVO/NegativePolicyEarnings","negativeEarnings");
>
> digester.addBeanPropertySetter("AgentStatementVO/AgentEarningsVO/NetPolicyEarnings","netEarnings");
>
> AgentStatement statement = (AgentStatement)digester.parse(xmlReader);
>
> Does anyone see what would be causing this behavior.
> I am using the following test xml.
>
> <AgentStatementVO>
> <StatementDate>2004/10/08</StatementDate>
> <AgentInfoVO>
> <FirstName/>
> <Name>xxxx</Name>
> <AgentId>xxxx</AgentId>
> <Address1>xxxx</Address1>
> <Address2>xxxx</Address2>
> <City>xxxx</City>
> <State>xx</State>
> <Zip>xxxxx</Zip>
> <AgentType>xxxx</AgentType>
> <DisbursementSource>xxxx</DisbursementSource>
> </AgentInfoVO>
> <AgentStatementLineVO>
> <AgentNumber>xxxx</AgentNumber>
> <ProductType>xxxx</ProductType>
> <FirstName>xxxx</FirstName>
> <Name>xxxx</Name>
> <EffectiveDate>2004/10/04</EffectiveDate>
> <ProcessDate>2004/10/05</ProcessDate>
> <OwnerName>xxxx</OwnerName>
> <PolicyNumber>0</PolicyNumber>
> <InitialPremium>0</InitialPremium>
> <CommissionRate>0.0</CommissionRate>
> <CommissionPremium>0</CommissionPremium>
> <Type>xxxx</Type>
> <AmountDue>0</AmountDue>
> </AgentStatementLineVO>
> <AgentEarningsVO>
> <TaxableIncome>0.0</TaxableIncome>
> <TaxableIncomeYTD>0.0</TaxableIncomeYTD>
> <PositivePolicyEarnings>0</PositivePolicyEarnings>
> <NegativePolicyEarnings>0</NegativePolicyEarnings>
> <NetPolicyEarnings>0</NetPolicyEarnings>
> </AgentEarningsVO>
> </AgentStatementVO>
>
> 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
Re: [digester] internal object not populated
Posted by Matt Goodwin <mg...@metalexis.com>.
Wendy,
Thanks for taking the time to recreate and solve the problem. I
won't get a chance to implement it until I go to work, but I'm positive
that will solve my problem.
Thanks a bunch,
Matt
Matt Goodwin
mgoodwin@metalexis.com
(515)708-0114
"Transcending the Ordinary"
Wendy Smoak wrote:
>From: "Matt Goodwin" <mg...@metalexis.com>
>
>
>>2 others are not populated (agentInfo - an AgentInfo object and
>>agentEarning - an AgentEarning object).
>>
>>
>
>Tentatively, because I don't have a lot of Digester experience... I see you
>create and populate the AgentInfo and AgentEarning objects, but I don't see
>you adding them to the AgentStatement object.
>
>I was able to recreate the problem, and solve it by adding these lines
>beneath their respective lists of addBeanPropertySetters:
>
>digester.addSetNext( "AgentStatementVO/AgentInfoVO", "setAgentInfo",
>"AgentInfo" );
>
>digester.addSetNext( "AgentStatementVO/AgentEarningsVO", "setAgentEarning",
>"AgentEarning" );
>
>(Note that I used the default package, so the third argument needs the
>correct package name added to the class name.)
>
>Now printing the AgentStatement object shows:
>[AgentStatement@1a5ab41 statementDate=2004/10/08
>agentInfo=[AgentInfo@1b90b39 lastName=xxxx] agentStatementDetails=[]
>agentEarning=[AgentEarning@1a8c4e7 positiveEarnings=0.0 netEarnings=0.0]]
>
>HTH, if you haven't solved it yourself by now. :)
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: [digester] internal object not populated
Posted by Wendy Smoak <ja...@wendysmoak.com>.
From: "Matt Goodwin" <mg...@metalexis.com>
> 2 others are not populated (agentInfo - an AgentInfo object and
> agentEarning - an AgentEarning object).
Tentatively, because I don't have a lot of Digester experience... I see you
create and populate the AgentInfo and AgentEarning objects, but I don't see
you adding them to the AgentStatement object.
I was able to recreate the problem, and solve it by adding these lines
beneath their respective lists of addBeanPropertySetters:
digester.addSetNext( "AgentStatementVO/AgentInfoVO", "setAgentInfo",
"AgentInfo" );
digester.addSetNext( "AgentStatementVO/AgentEarningsVO", "setAgentEarning",
"AgentEarning" );
(Note that I used the default package, so the third argument needs the
correct package name added to the class name.)
Now printing the AgentStatement object shows:
[AgentStatement@1a5ab41 statementDate=2004/10/08
agentInfo=[AgentInfo@1b90b39 lastName=xxxx] agentStatementDetails=[]
agentEarning=[AgentEarning@1a8c4e7 positiveEarnings=0.0 netEarnings=0.0]]
HTH, if you haven't solved it yourself by now. :)
--
Wendy Smoak
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org