Home
Analytics
Using dynamic pojos to generate BIRT reports at runtime?
dj-method-x
<p>I have an RCP application where a user basically fills out a form and clicks a save button. When they click the save button I want to generate a birt report.</p>
<p> </p>
<p>How can I accomplish this?</p>
<p> </p>
<p>Right now I create a pojo model object that contains all of the form data that the user has entered as strings.</p>
<p> </p>
<p>I have a report designed using a table.</p>
<p> </p>
<p>Right now I am trying to use a ScriptedDataSetEventAdapter implementation to generate the data in the report by overriding the fetch method and assigning values using the pojo to each column of each row.</p>
<p> </p>
<p>But my problem is that I have no way of getting the pojo to my ScriptedDataSetEventAdapter implementation. </p>
<p> </p>
<p>I have another class that sets up the Report Engine, opens the report design, and runs the report. This class gets has the pojo, but I cannot figure out how to get the pojo to my ScriptedDataSetEventAdapter implementation since it seems like this class is instantiated and called from the report design.</p>
<p> </p>
<p>Is there an easier way to do what I'm trying to describe?</p>
Find more posts tagged with
Comments
JFreeman
<p>You could use the Design Engine API (DEAPI) to create and/or modify the report design.</p>
<p> </p>
<p>Take a look over this documentation on DEAPI: <a data-ipb='nomediaparse' href='
https://www.eclipse.org/birt/documentation/integrating/deapi.php'>https://www.eclipse.org/birt/documentation/integrating/deapi.php</a></p>
;
dj-method-x
<blockquote class="ipsBlockquote" data-author="JFreeman" data-cid="134447" data-time="1426177018">
<div>
<p>You could use the Design Engine API (DEAPI) to create and/or modify the report design.</p>
<p> </p>
<p>Take a look over this documentation on DEAPI: <a data-ipb='nomediaparse' href='
https://www.eclipse.org/birt/documentation/integrating/deapi.php'>https://www.eclipse.org/birt/documentation/integrating/deapi.php</a></p>
;
</div>
</blockquote>
<p> </p>
<p>I already have a report design. All I want to do is pass the table the data that's in the pojo. I shouldn't have to change the design of the report to do this right?</p>
lumo
<p>i do provide my data via a scripted data source from my dynamic pojo's. (the pojo data source did not work for my purpose)</p>
<p>i doubt that you do need to change the report. i'd just change the way the data gets in (scripted data source)</p>
dj-method-x
<p>I overlooked the fact that ScriptedDataSetEventAdapter has a beforeOpen method that has a ReportContext as a parameter. I was able to inject a map containing all of my form data into my AppContext and then I get the AppContext from the ReportContext. From there I just loop through everything and assign the row column data. Pretty simple stuff
</p>
lumo
<p>do you use birt in an OSGi Service?</p>
<p>because i do something similar and run into problems see <a data-ipb='nomediaparse' href='
http://developer.actuate.com/community/forum/index.php?/topic/36280-birt-osgi-service-problem-bug/'>this
thread</a></p>
<p>could you check if you do it the same way and let me know if you have the same problem?</p>
<p> </p>
<p>if you do not have this problem could you create a small example (alter mine?) which demonstrates how you do it?</p>
dj-method-x
<p>This actually will be in an OSGI bundle, but is not yet. If I have problems I will report back and let you know!</p>
lumo
<p>please also report back if you got it working, because i got the problem that generating the report does not work (though preview works without problems) probably you 'solve' my problem just by posting how you did it. (code)</p>
<p> </p>
<p>thanks!</p>