StimVinsh / xdocreport

Automatically exported from code.google.com/p/xdocreport
0 stars 0 forks source link

Support for grouping #86

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,

First of all I find this project extremely useful and would like to thank 
everyone involved for all the hard work.

Now I have this problem I can't handle. Lets say that there is a map whose key 
is a Project object, and whose value is list of Developer objects. I would like 
to somehow create a heading for the Project, and then below it a table that 
would list developers involved in that project.

As there is unknown number of projects I can't define all the tables in a 
template and use different list for a different table. Basically I need a way 
to tell the inner loop not to fetch the source list by name but some other 
mechanism. Maybe something like:
    metadata.addContextualList("developers", "contract.developers");

I'm sorry if I overlooked something really basic, I just found out about this 
project today. If it matter my template is in ODT format, with freemarker as a 
templating language.

Original issue reported on code.google.com by alh84001...@gmail.com on 8 Mar 2012 at 5:54

GoogleCodeExporter commented 8 years ago
In the above case, the outer loop of the template could then be

[#list foo as contract]
...
[/#list]

Original comment by alh84001...@gmail.com on 8 Mar 2012 at 6:01

GoogleCodeExporter commented 8 years ago
Hi,

>First of all I find this project extremely useful and would like to thank 
everyone >involved for all the hard work.
Many thanks!

If I understand your need, you want loop for project and generate for each 
project: 

 * information about project.
 * list of developpers in a table.

I think to simplify the report you should put in the context list of 
ProjectWrapper   

* which extends Project. 
* define a getter of list of developpers.

1) After you can define at start of your document a list freemarker : 

-------------------------------
[#list projects as p]
-------------------------------

2) Don't use FieldsMetadata

Today FieldsMetadata manage list but as you have a context (p), you cannot use 
it. So you should use 
http://code.google.com/p/xdocreport/wiki/ODTReportingJavaMainListFieldAdvancedTa
ble use @before-row/@after-row in the table like this : 

-------------------------------
@before-row[#list developers as p.developers]
...
-------------------------------

But I agrre with you to simplify the report, I think we should improve 
FieldsMetadata to set which key is a list or not like this :

-------------------------------
metadata.addKey("p").addList("developers").addKey("name").
-------------------------------

Tell me if @before-row is OK with you.

Regards Angelo

Original comment by angelo.z...@gmail.com on 9 Mar 2012 at 8:27

GoogleCodeExporter commented 8 years ago
That is just what I need. I just skimmed through that page while reading the 
documentation and eventually just forgot about it.

I tried to test it, but now I got a really strange error when converting to PDF.

 java.lang.NoSuchMethodError: org.odftoolkit.odfdom.converter.internal.itext.stylable.StylableTableCell.setRowspan(I)V
    at org.odftoolkit.odfdom.converter.internal.itext.ElementVisitorForIText.visit(ElementVisitorForIText.java:400)
...

I downloaded these two files from the download page and merged them:
odtandvelocity.converters-0.9.6-sample.zip
odtandfreemarker-0.9.6-sample.zip

Browsing the source code of the 0.9.6 tag on GIT I see that indeed the method 
setRowspan is being called in ElementVisitorForIText and yet it doesn't exist 
in StylableTableCell.

Also I have really simple tables in the document with no merged rows, so I 
guess either cells get assigned 1 for rowspan and colspan by LibreOffice or the 
converter does some manipulation internally).

I will try to avoid converting and just merge to ODF to see if the merging 
itself works.

Original comment by alh84001...@gmail.com on 9 Mar 2012 at 2:52

GoogleCodeExporter commented 8 years ago
java.lang.NoSuchMethodError: 
org.odftoolkit.odfdom.converter.internal.itext.stylable.StylableTableCell.setRow
span(I)V
    at org.odftoolkit.odfdom.converter.internal.itext.ElementVisitorForIText.visit(ElementVisitorForIText.java:400)

Indded that's very strange. perhaps our distribution is bad? The better mean to 
get XDocReport JARs is to use maven => 
http://code.google.com/p/xdocreport/wiki/XDocReport096

Regards Angelo

Original comment by angelo.z...@gmail.com on 9 Mar 2012 at 3:17

GoogleCodeExporter commented 8 years ago
OK, I tried only merging the template with the model and it performed 
beautifully :)

Regarding the above error, it was my error. I was using an outdated iText 
version, and required methods were added in version 2.1.6.

Thank you for the help.

Original comment by alh84001...@gmail.com on 9 Mar 2012 at 4:47

GoogleCodeExporter commented 8 years ago

Original comment by angelo.z...@gmail.com on 13 Mar 2012 at 2:41