Question

Performing a test with BIRT I was able to create a report and render it in PDF, but unfortunatelly I'm not getting the expected result.

For my DataSource I created a Scripted DataSource and no code was needed in there (as far as I could see the documentation to achieve what I'm trying to do).

For my DataSet I create a Scripted DataSet using my Scripted DataSource as source. In there I defined the script for open like:

importPackage(Packages.org.springframework.context);
importPackage(Packages.org.springframework.web.context.support);

var sc = reportContext.getHttpServletRequest().getSession().getServletContext();

var spring = WebApplicationContextUtils.getWebApplicationContext(sc);

myPojo = spring.getBean("myDao").findById(params["pojoId"]);

And script for fetch like:

if(myPojo != null){
       row["title"] = myPojo.getTitle();
       myPojo = null;
       return true;
}
return false;

As the population of row will be done on runtime, I wasn't able to automatically get the DataSet columns, so I created one with the following configuration: name: columnTitle (as this is the name used to populated row object in fetch code).

Afterwards I edited the layout of my report and added the column to my layout.

I was able to confirm that spring.getBean("myDao").findById(params["pojoId"]); is executed. But my rendered report is not showing the title. If I double click on my column label on report layout I can see there that expression is dataSetRow["columnTitle"] is it right? Even I'm using row in my fetch script? What am I missing here?

Was it helpful?

Solution 2

The problem was the use of batik twice (two different versions), one dependency for BIRT and other for DOCX4J.

The issue is quite difficult to identify because there is no log output rendering PDF files.

Rendering HTML I could see an error message which I could investigate and find the problem.

For my case I could remove the DocX4j from maven POM.

OTHER TIPS

Well, what is conctractVersion? It is obviously not initialized in the open event. Should this read myPojo.contractVersion or perhaps myPojo.getContractVersion()?

Another point: Is the DS with the column "columnTitle" bound to the layout?

You should also run your report as HTML or in the previewer to check for script errors. Unfortunately, these are silently ignored when generating the report as PDF...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top