I have recently started using BIRT for some very simple reporting in a Java\SQL Server application. By the logic of the application the user will select a certain database record to view (generally a JComboBox of jobNumbers) at this point I want to create a report in BIRT for this jobNumber. I have the basic report design and I can open it from my Java app using IRunAndRender but I can't get a data parameter to work.
I have a Where jobNum = ? in my dataSet SQL and I can set it up to prompt the user to enter the job number but I want to pass the report the job number that is already displayed on the form the user is looking at (it is in a JTextfield).
How can I pass a parameter value to the BIRT report so it only displays the correct record?
posted 13 years ago
I will answer this question myself just in case someone else struggles with the same issue. Passing a parameter from Java to BIRT is a several step process (this may not be the best way but it does work)
Assuming that BIRT is installed with Eclipse and functional try the following:
In your report design add a new Report Parameter ( RP_param )
In your data set Query create your query with something like "WHERE ID = ?" or some other criteria using a ? for the value.
In your data set add a Parameter ( DS_param ) then set the default value of this parameter to the Report Parameter you created earlier (RP_param) to do this click on the default value field then the ... button. In the resulting dialog choose Category 'Report Parameters', sub category 'All' then double click your Report Parameter to add it and click OK.
[list]In the Java code do something like This will send the value of paramValue to your Report Parameter RP_param which will in turn send the value to the dataset parameter DS_param which will cause the report to run with the proper data.
[ September 05, 2006: Message edited by: Deroga Rivera ]
can you explain a little more in detail about this code? Where do I write this code?
I am using struts in my application. Do i write this in the action class of the jsp page
which forwards to the report?
What is reportDesignFile?
What is engine?