Two Laptop Bag
The moose likes Other Open Source Projects and the fly likes BIRT report parameter from Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "BIRT report parameter from Java" Watch "BIRT report parameter from Java" New topic

BIRT report parameter from Java

Deroga Rivera

Joined: Aug 04, 2005
Posts: 13
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?

Deroga Rivera

Joined: Aug 04, 2005
Posts: 13
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 ]
    Neeti Raghunath

    Joined: Mar 16, 2009
    Posts: 4

    I am trying to pass parameter to BIRT from java....

    You had mentioned :

    In the Java code do something

    IReportRunnable design;[/list]
    IRunAndRenderTask task = null;

    design = engine.openReportDesign(reportDesignFile);
    task = engine.createRunAndRenderTask(design);

    // {... other code... }

    task.setParameterValue("RP_param", paramValue);;

    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?

    Martijn Verburg

    Joined: Jun 24, 2003
    Posts: 3275

    Hi Neeti and welcome to Javaranch!

    Could you please post your question in a new topic? We try not to Wake the Zombies around here

    Cheers, Martijn - Blog,
    Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
    My start-up.
    shubhi mehrotra

    Joined: Mar 29, 2010
    Posts: 1
    Thanks Buddy,
    This onw worked for me

    Thanks & Regards,
    I agree. Here's the link:
    subject: BIRT report parameter from Java
    jQuery in Action, 3rd edition