Jump to content
We've recently updated our Privacy Statement, available here ×

Passing parameters not from SQL query


bjodasso

Recommended Posts

 I am wanting to pass parameters to a .jrxml file where my data source is not  a SQL query, but values input into a JTable.

I can easily get one row of data passed into the report but I cannot seem to find out how to pass in multiple values with the same hashmap key (column name from the table). See the code below for what I currently have.

As you can see, since im not using a database connection, I just pass in an empty data source to the fillReport. Like I said I can get one row into the report fine, but if I try to pass an array of values into val, it won't work. Also, i'm just showing one column of the JTable here (itemName), but I think you get the picture. I want to pass multiple values for each key and have them all display in the report.

Do I need to set up the report parameters or a dataset in a certain way to allow for this? Do I need to create a List element? and if I do what do I set the data source as for the list? Any help is appreciated thanks.

Brad

Code:
  for (int i = 0; i < mTable.getRowCount(); i++)  {      val = (String) mTable.getValueAt(i, 0);       jasperParameter.put("itemName", val);  }  jasperReport = JasperCompileManager.compileReport(reportTemplate);  jasperPrint = JasperFillManager.fillReport(jasperReport, jasperParameter, new JREmptyDataSource());
Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...