Jump to content

Recommended Posts

Posted

Hi,

I'm new to jasper reports. I have created a simple report where data is extracted from a mysql database. No problem.
But when I try to pass parameters to the report where a I want to filter the data with a IN clouse, I allways get all results or an error.

This is my code:

$controls = array('Parameter_1' => array('ANT' => 'ANT', 'LIE' => 'LIE'));                  
$report = $client->runReport('/reports/Test/Formulier_0', 'pdf', null, $controls);
 
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Description: File Transfer');
header('Content-Disposition: attachment; filename=report.pdf');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . strlen($report));
header('Content-Type: application/pdf');
 
But with this code the full report is given instead of the filtered report
When I change the array into $controls = array('Parameter_1' => array( 'ANT',  'LIE'));
I get an error "Invalid type java.lang.String for parameter Parameter_1 used in an IN clause; the value must be an array or a collection."
 
This is the report dataset:
 
SELECT vzvb.cms_clubs.club_id,
vzvb.cms_clubs.club_naam,
vzvb.cms_clubs.club_nr,
vzvb.cms_clubs.club_province
FROM vzvb.cms_clubs
where $X{IN,  vzvb.cms_clubs.club_province, Parameter_1} 
ORDER BY vzvb.cms_clubs.club_province ASC,
vzvb.cms_clubs.club_naam ASC
 
Parameter_1 is defined as a java.lang.String
 
What am I doing wrong?
 
Thanks in advance.
 
Regards,
 
Bart
  • 7 months later...
  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Posted

I think you gave the answer yourself, you said ' Parameter_1 is defined as as java.lang.String'  and the error sais: ' Invalid type java.lang.String for P1 (..) value must be an array or a collection.' 

Can you try to change you parameterer type (can be found in properties of your param) to 'java.util.ArrayList' or 'java.util.Collection'. 

That should work, and if you only use Strings in the array/collection, you can define 'Nested subtype'  to 'java.lang.String' so you don't have to define the type as well on each object.

Can you let me know if it worked? 

  • 3 weeks later...
Posted

Hi Gert_1

 

I created a new report where I needed this and now it works.

I think that the php array I was passing in the parameter was malformed or wrong...

 

Thank you for the hint.

 

Regards

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...