pass several parameters in the ireport

Asked

Viewed 703 times

1

I have the following problem: I created in java a selectcheckbox, where the person will select multiple objects; when sending to the managed bean, I can receive these listed objects. I now want to send as a parameter to ireport for it to generate a report with the information that was selected.

In the other methods use the following:

Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("codigo", agencias.getId());

    JasperImpressao jp = new JasperImpressao();

    jp.imprimirRelatorioPdf(parameters, "agencia.jasper");

This "jp.imprimirRelatorioPdf" does everything; if I use code it prints normal. So I thought: there in my sql do ireport, instead of using the

WHERE agencias.`id` = $P{codigo}"

use the

WHERE agencias.`id` IN $P{codigo}"

Then in this parameter "code" I would pass a string with the id of the agencies I want to print: it would be "Where agencies in "1,2,3"

but this does not work, gives syntax error.

How could I do that?

2 answers

1

check the type of the variable $P{codigo} in the Jasper, to work with the value "1,2,3" inside it, it must be of the type String.

And to work on SQL your query string has to stay:

SELECT * FROM agencias WHERE agencias.id IN (1,2,3)

0


select * from customer where $X{IN,customer_role,roles}

  • 1

    Adriano, consider explaining your answer. It may be that for you the code is easy to understand, but for others, without an answer with details, it’s the same thing as copying and pasting.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.