commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sash <swis...@gmail.com>
Subject Re: betwixt list xml to bean problem, please help
Date Fri, 01 Jun 2007 13:30:43 GMT
Problem solved.  My ProductTO object also has a List field.  Seems that if
you have a list field, you must provide a getter, setter and an add method.
I forgot to add the add method for the ProductTO class.  Seems silly though
and just guessing how implemented, but could check class and if add method
is missing, create a list variable, fill it and then use the setter method.
Anyway, great library non the less.



On 5/30/07, Sash <swishey@gmail.com> wrote:
>
> Hi,
>
> I've been using betwixt for a couple of days, really new to this library.
> Anyway, using the sample provided on the site, have been able to write
> simple beans to xml and then back again.  However, when I tried to use a
> bean that had a List of other beans, I got a weird result.  The xml is
> created properly, but when I try to create the bean from xml, an empty
> object array is created of correct length but with null values.  If the list
> contained only one element, then everythign works correctly.  What am I
> doing wrong or what am I not doing.  Tried with betwixt 0.6 to 0.8.
> Thank you in advance for your comments!
>
> XML
> -----------------------
> <?xml version="1.0" encoding="UTF-8"?>
>   <CatalogTO>
>     <productTOs>
>       <productTO>
>         <productCode>P200036</productCode>
>         <productName>??  </productName>
>         <productPk>200036</productPk>
>         <amount>4.99</amount>
>         <productType>drmasset</productType>
>         <oneTimeFlag>F</oneTimeFlag>
>         <activeDate>Mon Mar 26 22:10:00 EST 2007</activeDate>
>         <lastModifiedDate>Wed May 23 14:36:31 EDT 2007</lastModifiedDate>
>         <standardAssetPksStr>200204,212260</standardAssetPksStr>
>         <productLevel>simple</productLevel>
>         <standardAssetPks>
>           <Long>200204</Long>
>           <Long>212260</Long>
>         </standardAssetPks>
>         <optionWeight>0</optionWeight>
>       </productTO>
>       <productTO>
>         <productCode>P200159</productCode>
>         <imageUrl>/images/products/1177625345014.jpg</imageUrl>
>         <productName>12 Monkeys - P200159</productName>
>         <productPk>200159</productPk>
>         <amount>1.0</amount>
>         <productType>perpetual_serial</productType>
>         <oneTimeFlag>F</oneTimeFlag>
>         <activeDate>Wed Apr 25 15:52:31 EDT 2007</activeDate>
>         <lastModifiedDate>Fri Apr 27 10:42:34 EDT 2007</lastModifiedDate>
>         <standardAssetPksStr>200018</standardAssetPksStr>
>         <productLevel>simple</productLevel>
>         <standardAssetPks>
>           <Long>200018</Long>
>         </standardAssetPks>
>         <optionWeight>0</optionWeight>
>       </productTO>
>     </productTOs>
>   </CatalogTO>
>
> CatalogTO class
> --------------------------
> public class CatalogTO implements Serializable {
>  private List productTOs = new ArrayList();
>  public List getProductTOs() {
>   return productTOs;
>  }
>  public void addProductTO(ProductTO productTO) {
>   productTOs.add(productTO);
>  }
>  public void setProductTOs(List productTOs) {
>   this.productTOs = productTOs;
>  }
> }
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message