• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

BIRT report parameter from Java

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?

Thanks.
 
Deroga Rivera
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
     
    Greenhorn
    Posts: 4
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi

    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);
    task.run();


    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?

    Thanks
    Neeti
     
    author
    Posts: 3285
    13
    Mac OS X Eclipse IDE Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    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
     
    Greenhorn
    Posts: 1
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thanks Buddy,
    This onw worked for me
     
    Consider Paul's rocket mass heater.
    reply
      Bookmark Topic Watch Topic
    • New Topic