Parameters not being passed to iReport

Discuss all problems you have with Servoy here. It might help to mention the Servoy version and Operating System version you are using

Parameters not being passed to iReport

Postby sam » Tue Jan 29, 2013 5:16 pm

Im currently using Servoy 7 (Latest Build) along with iReports Version 5 but am having problems getting a simple parameter to be passed from my code to the Report

The following is the code for a simple button to view the report in my Servoy Solution

Code: Select all
/**
* Perform the element default action.
*
* @param {JSEvent} event the event that triggered the action
*
* @properties={typeid:24,uuid:"ED06AA59-4A82-4898-B0C0-B17321453011"}
*/
function btnPrintRPT(event) {

//      var params = new java.util.HashMap()
//      params.put("operator_code", '"SAMJ"')
//      var serverName = databaseManager.getServerNames();      
      var params = new Object();
      params.operator_code = forms.ReportTest.user_code;
//      params.parameter2 = 2;
      
      plugins.jasperPluginRMI.runReport("acss", "report4.jrxml", null, "print", params);
   }


Below is the SQL query for the report in iReport the operator_code parameter was set up accordingly as a Java String Parameter
Code: Select all
SELECT
     operators."operator_id" AS operators_operator_id,
     operators."creation_date" AS operators_creation_date,
     operators."name" AS operators_name,
     operators."user_code" AS operators_user_code
FROM
     "public"."operators" operators
WHERE
operators."user_code" = $P{operator_code}


I have tried changing various things to try and get it working such as defining the params variable as an object or a new java Hash Map all to no avail. Any help or obvious errors I have over looked would be greatly appreciated
sam
 
Posts: 4
Joined: Thu Jan 24, 2013 3:23 pm

Re: Parameters not being passed to iReport

Postby Thomas Parry » Wed Jan 30, 2013 3:24 am

I see a couple of issues you need to be aware of:
1. iReport version 5 may not work with the version of the JasperReports plugin shipped with Servoy v7. Check on the libraries shipped with Servoy v7.(I assume you are using that plugin?)

2. In your where clause you might try adding the "!" after the $P:
Code: Select all
operators."user_code" = $P!{operator_code}
Tom Parry
Prospect IT
Java/C++/Servoy/Jasper Reports/Simulation/Service Applications
http://www.prospect-saas.biz
Thomas Parry
 
Posts: 498
Joined: Thu Jan 10, 2008 8:48 pm
Location: Ottawa, Canada

Re: Parameters not being passed to iReport

Postby jdbruijn » Wed Jan 30, 2013 9:50 am

Thomas Parry wrote:2. In your where clause you might try adding the "!" after the $P:
Code: Select all
operators."user_code" = $P!{operator_code}

As far as I know you only need to do this when you are inserting SQL code into the statement.
Lets say you provide filter information from servoy to fill the following sql query in your iReport:
Code: Select all
SELECT fields FROM table WHERE $P!{CONDITIONS}

you can provide the filters as this:
Code: Select all
params.put('CONDITIONS', 'field_1=21 AND field_2="abc"'


I think the problem is indeed in the iReport version that you are using. Check the servoy forge Wiki for information about versions:
https://www.servoyforge.net/projects/servoy-jasperreports/wiki
Jos de Bruijn
Focus Feedback BV
Servoy Certified Developer
Image
jdbruijn
 
Posts: 492
Joined: Sun Apr 11, 2010 6:34 pm

Re: Parameters not being passed to iReport

Postby Mark Crichton » Wed Jan 30, 2013 10:18 am

I use iReport 3.7 with plugin 3.2.0 with great success.

Couple of questions.
1. You don't mention if you are getting any error message.
2. Does the report run correctly directly out of iReport? I have found it easier to debug run reports using data connection in iReport rather than passing a found set.
Mark Crichton
DataWise Ltd - New Zealand
http://www.datawise.co.nz
User avatar
Mark Crichton
 
Posts: 109
Joined: Mon Jan 24, 2011 10:01 am
Location: Auckland, New Zealand

Re: Parameters not being passed to iReport

Postby sam » Wed Jan 30, 2013 12:49 pm

Thanks for the quick responses, much appreciated

To answer your questions I was indeed receiving an error but there was no details with it other than wrapped java exception. Also the report was running fine out of iReports.

I have since gone back and looked at the versions and changed my Jasper Plugin version from 3.3.1 to 4.0 and the code I listed in the original post now works fine. I am assuming it was just a compatibility issue that I had over looked.
sam
 
Posts: 4
Joined: Thu Jan 24, 2013 3:23 pm


Return to Discuss possible Issues and Bugs

Who is online

Users browsing this forum: Bing [Bot] and 10 guests