This week's book giveaways are in the AI and JavaScript forums.
We're giving away four copies each of GANs in Action and WebAssembly in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

BIRT report parameter from Java

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • 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
  • 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
    • 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: 3281
    8
    Mac OS X Eclipse IDE Java
    • Mark post as helpful
    • send pies
    • 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
    • Quote
    • Report post to moderator
    Thanks Buddy,
    This onw worked for me
     
    She'll be back. I'm just gonna wait here. With this tiny ad:
    Java file APIs (DOC, XLS, PDF, and many more)
    https://products.aspose.com/total/java
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!