Pass multiple parameters

0

To pass parameters, I can do the following.

Map parameters = new HashMap(); parameters.put("imageDir", imageDir);

What if I wanted to pass 100 strings? Do I need to write 100 statements like the one above? Or can I pass them as a list or something? If so, how do I access it from my jrxml?

Thanks,

Malliboy.

 

malliboy's picture
Joined: Jul 21 2009 - 9:19pm
Last seen: 5 years 2 months ago

5 Answers:

0
hi , you can pass the list from java to jrxml, create a parameter of type java.util.Collection or java.util.List in the jrxml.....
dayana's picture
32
Joined: Jul 8 2009 - 10:50pm
Last seen: 5 years 2 months ago
0

You can put a List object in your parameter map. Then you have just to declare a parameter like this in your jrxml file: <parameter name="imageDir" isForPrompting="false" class="java.util.List"/> To use it in an expression you can write for example: $P{imageDir}.get(0)

jpp74's picture
7
Joined: Aug 3 2009 - 9:02am
Last seen: 1 month 2 weeks ago
0

Thanks a ton for that. :)

malliboy's picture
Joined: Jul 21 2009 - 9:19pm
Last seen: 5 years 2 months ago
0

If you use a List or a Collection, we can refer it only by the index. I was looking for a key-value pair. Yes, adding them to the 'parameters' hashmap serves the purpose, but again, if I need to pass 100 strings, I need to explicitly include the parameters in the jrxml. I was looking for a solution and found one - Another hashmap within 'parameters'.

HashMap myMap = new HashMap(); myMap.put("1", "A"); myMap.put("2", "B"); myMap.put("3", "C");

Map parameters = new HashMap(); parameters.put("myMap", myMap);

In the jrxml, fetch values using '$P{myMap}.get("1")'. The advantage is that we don't to specify A, B and C in the parameter section of the jrxml. Looks like anything - Tree, Map can be used. Hope that helped. :)

 

 

 

malliboy's picture
Joined: Jul 21 2009 - 9:19pm
Last seen: 5 years 2 months ago
0

Hello. Could you please guide me, how to access java list ,passed to ireport in a hashmap, objects's attributes.

Regards,

Ranjet

rawat143's picture
Joined: Sep 11 2012 - 11:37pm
Last seen: 2 years 1 week ago
Feedback
randomness