Hi Peter,
There are two ways you could handle this, but neither one is completely
painless.
The first approach is to get the marshalling context, cast it to the
implementation class org.jibx.runtime.impl.MarshallingContext, call
startDocument() to set up the output, call startTag(0, "jobs") to write
the outer element start tag, call marshalCollection(collection) to
marshal out all the individual job items in the collection, call
endTag(0, "jobs") to write the outer element end tag, and call
endDocument() to close the output.
The other is to use a custom collection class, which can be as simple as:
public class MyCollection extends Collection {}
Since this is *your* class, you can define a <mapping> for this in your
binding definition and have it handled automatically.
- Dennis
Peter Whitfield wrote:
Hi All,
Apologies for this newbie question, but I wasn’t able to find the
answer in previous posts…
I am looking at using jibx for marshalling a collection of objects
into a ServletResponse for consumption by an OpenLaszlo application.
I’d like to end up with XML something like:
<jobs>
<job>
<name>blah</name>
Etc
</job>
<job>
…
</job>
</jobs>
At present I have the following binding definition:
<binding>
<mapping name="job" class="com.vizability.jobman.biz.jobs.Job">
<value name="name" field="name"/>
<value name="description" field="description"/>
<value name="dateRequired" field="dateRequired"/>
<value name="priority" field="priority"/>
<value name="quoteNum" field="quoteNum"/>
<value name="invoiceNum" field="invoiceNum"/>
<value name="id" field="id"/>
<value name="poNum" field="poNum"/>
<value name="proofsRequired" field="proofsRequired"/>
<structure name="client" field="client">
<structure field="clientOrg">
<value name="name" field="name"/>
<value name="id" field="id"/>
<value name="contact" field="contact"/>
<value name="contactPhone" field="contactPhone"/>
</structure>
</structure>
<structure name="payer" field="payer">
<structure field="payingOrg">
<value name="name" field="name"/>
<value name="id" field="id"/>
<value name="contact" field="contact"/>
<value name="contactPhone" field="contactPhone"/>
</structure>
</structure>
</mapping>
</binding>
Is it possible to generate the jobs collection without defining a
specific collection class?
Thanks for any help J
Cheers,
Pete
-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users