Closed GoogleCodeExporter closed 8 years ago
Hi,
I understand what you wish do. I don't know if it's possible to do that but I
will study that.
Regards Angelo
Original comment by angelo.z...@gmail.com
on 12 Aug 2011 at 9:30
Hi,
I have tested with our provided samples (lits of developer) with ODT + Velocity
(but it will works too with docx and Freemarker).
I will add page in teh wiki to explain how manage list of list in a Table cell.
If you take the sample with developer (docx+velocity) you have :
* a list of developer in a Table. You have the field $developers.Name in a inpout file (for ODT) and mergefield (for docx).
* Velocity Loop for table is generated automaticly because there is Fieldsmetdata FieldsMetadata metadata = new FieldsMetadata();
metadata.addFieldAsList("developers.Name");
With simplification, XDocReport use fieldsmetadata to transform the odt/docx
original :
----------------------------------------
<table>
<row>
<cell>$developers.Name</cell>
</row>
<table>
----------------------------------------
with this content :
----------------------------------------
<table>
#foreach($item_developers in developers)
<row>
<cell>$item_developers.Name</cell>
</row>
#end
<table>
----------------------------------------
You can check that XDocReport transform your $developers with $item_developers.
So if you know that you can manage your list of list.
Imagine you have Developer#getRoles(), and Role#getName() and you put your
context like this :
---------------------------------------------
Developer developer = new Developer("ZERR",
"Angelo", "angelo.zerr@gmail.com");
developer.addRole(new Role("Role1"));
developer.addRole(new Role("Role2"));
---------------------------------------------
You can write the odt/docx like this :
----------------------------------------
<table>
<row>
<cell>$developers.Name</cell>
<cell>#foreach ($role in $item_developers.Roles) $role.Name
#end</cell>
</row>
<table>
----------------------------------------
where Velocity code is included in a input-field/mergefield :
* #foreach ($role in $item_developers.Roles)
* $role.Name
* #end
The ouput looks like this :
----------------------------------------
<table>
<row>
<cell>ZERR</cell>
<cell>Role1
Role2
</cell>
</row>
<table>
----------------------------------------
After Role2 you will extra line break (I don't know for the moment how fix
that).
Regards Angelo
Original comment by angelo.z...@gmail.com
on 12 Aug 2011 at 2:40
Thanks so much.
Will try that and update you.
Original comment by murthy.r...@gmail.com
on 12 Aug 2011 at 5:30
Original comment by angelo.z...@gmail.com
on 1 Nov 2011 at 4:01
Original issue reported on code.google.com by
murthy.r...@gmail.com
on 12 Aug 2011 at 6:33Attachments: