Using custom Java class-defined template

Hello. Thanks for the reports module, but I have a tiny problem - lack of information how to add a custom class-defined template.

  • I wrote a class
SampleReport implements CustomReport,
  • overridden
createReport

method, which for example returns

"HelloWorld".getBytes();

.
But found no further information about how to use it.

  • I put it to my core module,
  • load it as a template,
  • set output type to custom
  • set output filename to
sample.txt
  • check custom template
  • pick Java class as a definition type
    but if a write it’s name to a Definition field i get a ClassNotFoundException: SampleReport

Hello, Ivan.

You should set a fully qualified name of your Java class when you use it as a class-defined template, for example:

com.company.customjavaclassreporttemplate.core.reports.customtemplates.SampleReport

Best regards,
Daniil.

Thanks a lot! I think you should insert this answer to official manual, cos it’s not obvious in 1.2.4

Yes, we will add more info about it.

So i add everything as it should, my report generates a text file, but… How to read band’s result? I got a band, say, dataBand which have a list of maps called result in my groovy dataset which looks like
[ [ 'enum': 1, 'payload': 'hello' ], [ 'enum': 2, 'payload': 'world' ] ]

in my java-defined template i have
return rootBand.getChildByName("dataBand").getData().toString().getBytes
which returns me only a first map in list [ 'enum': 1, 'payload': 'hello' ]. how to get next results in this dataset?

Hello, @ocrio.box

This question is not related to the topic subject. Please create a new topic with detailed explanation.

Regards,
Daniil.

sure, here it is, thank you Getting report rows from a java-class defined template