malliboy Posted August 3, 2009 Share Posted August 3, 2009 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. Link to comment Share on other sites More sharing options...
dayana Posted August 4, 2009 Share Posted August 4, 2009 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..... Link to comment Share on other sites More sharing options...
jpp74 Posted August 4, 2009 Share Posted August 4, 2009 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) Link to comment Share on other sites More sharing options...
malliboy Posted August 4, 2009 Author Share Posted August 4, 2009 Thanks a ton for that. :) Link to comment Share on other sites More sharing options...
malliboy Posted August 5, 2009 Author Share Posted August 5, 2009 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. :) Link to comment Share on other sites More sharing options...
ranjeet143 Posted September 12, 2012 Share Posted September 12, 2012 Hello. Could you please guide me, how to access java list ,passed to ireport in a hashmap, objects's attributes.Regards,Ranjet Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now