Keith-
Thanks for the correction. I guess I shouldn't write technical e-mails
before 8 in the morning :)
Stephen
Keith Visco wrote:
Small typo in the below suggestion:
collection="false" should read container="false".
By default Castor treats collections as "containers". Containers to
Castor are simple objects whose only purpose is to hold other objects.
Containers are not considered "first-class" objects and therefore have
no direct XML representation. By setting container="false", you are
telling Castor that the collection is not be treated as a container, but
rather a first class object which should have an XML-representation.
--Keith
Stephen Bash wrote:
James-
I think you have two options. First, what I often do is use the
location attribute in my bind-xml element to wrap collections in
whatever element I want. Your other option was covered recently on
this mailing list, and that is to set collection="false" in the field
element for the list. It seems counter-intuitive (and has been
admitted as so I believe), but by setting that attribute Castor
recognizes you want an element wrapping the members of the list.
HTH,
Stephen
James Adams wrote:
I am trying to map a List but have yet to work out the correct Castor
mapping. When I let Castor auto-complete the class which contains
the List I get all of the elements of the list at the same level.
For example if my object contains a List of two elements I will get
XML which looks like the following:
<my-object>
<list-element>
<element-field/>
</list-element>
<list-element>
<element-field/>
</list-element>
</my-object>
Instead I am trying to get XML which looks like this:
<my-object>
<my-list>
<list-element>
<element-field/>
</list-element>
<list-element>
<element-field/>
</list-element>
</my-list>
</my-object>
I have tried using a mapping.xml with the following entry:
<class name="MyObject"
auto-complete="true">
<!--
<field name="myList"
collection="arraylist"
type="MyListClass"/>
-->
</class>
I get the first example XML whether or not I use the <field> element
in the <class> mapping element above.
The List member of the class I'm mapping is actually a List<E>, in
that it is a List of objects of a class which is also mapped in the
mapping.xml. Maybe Castor doesn't yet support generics, but I haven't
seen anything to that effect in the documentation.
Can someone steer me in the right direction? Thanks in advance for
any suggestions!
--James
-------------------------------------------------
If you wish to unsubscribe from this list, please send an empty
message to the following address:
[EMAIL PROTECTED]
-------------------------------------------------
-------------------------------------------------
If you wish to unsubscribe from this list, please send an empty
message to the following address:
[EMAIL PROTECTED]
-------------------------------------------------
-------------------------------------------------
If you wish to unsubscribe from this list, please send an empty message
to the following address:
[EMAIL PROTECTED]
-------------------------------------------------
-------------------------------------------------
If you wish to unsubscribe from this list, please
send an empty message to the following address:
[EMAIL PROTECTED]
-------------------------------------------------