Sorry if you get this twice, my email seems not to get through to the list,
so i sent it again.
Hi Ravi,
i had the same problems and figured out that i need those .betwixt files.
Imagine a configuration having different entrys.
<?xml version="1.0" encoding="UTF-8"?>
<info primitiveTypes="attribute">
<element name="configuration" class=''de.grobmeier.Configuration'>
<element name="entry"
property="entry"
class='de.grobmeier.Entry'>
<addDefaults/>
</element>
<addDefaults/>
</element>
</info>
Here is my Configuration class:
public class Configuration {
private List<Entry> entries= new ArrayList<Entry>();
public List<Entry> getEntry() {
return entries;
}
public void addEntry(_entry) {
entries.add(_entry);
}
}
Mind that addEntry Method please.
My Entry-Class is a simple POJO. I figured out i need a betwixt file
here to, altough i thought this was mapped "by default", however, its
similar to this:
<info primitiveTypes="attribute">
<element
name="entry"
property="entry"
class='de.grobmeier.Entry'>
<attribute name='key' property='key'/>
<attribute name='value' property='value'/>
</element>
</info>
I had to register only the configuration class:
beanReader.registerBeanClass("configuration", Configuration.class);
configuration = (Configuration)beanReader.parse(reader);
Hope this helps,
Best,
Chris
On 10/16/07, Ravindra Wankar <[EMAIL PROTECTED]> wrote:
>
>
> No. I'm trying to get all the person objects into an ArrayList.
>
> Thanks
> Ravi.
>
>
> Eckenfellner Klaus wrote:
> Does your collection-bean have adder-functions for the person-beans?
>
> please see example at
> http://commons.apache.org/betwixt/guide/examples.html
> (bottom of page).
>
> Ravindra Wankar wrote:
>
>
> How do I convert an XML to bean collection?
>
> XML:
> <persons>
> <person>
> <name>A</name>
> <age>21</age>
> </person>
> <person>
> <name>B</name>
> <age>25</age>
> </person>
> <person>
> <name>C</name>
> <age>32</age>
> </person>
> </persons>
>
> Java code:
>
> beanReader.registerBeanClass("persons", ArrayList.class);
> beanReader.registerBeanClass("persons/person", Person.class);
> ArrayList persons = (ArrayList)beanReader.parse(xmlReader);
>
> I get an empty list. I'm using Betwixt 0.8, Digester 1.8, BeanUtils 1.7
>
> Thanks
> - Ravi.
>
> ---------------------------------------------------------------------
> 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]
>
>
>
> ---------------------------------------------------------------------
> 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]