How do I repeat a Jasper Reports Expression once for every item in a Java Collection?

I have a field on my main report called jobPurchaserCollection which is a Java Collection containing objects of the custom type jobPurchaser.

jobPurchaser contains several fields, including firstName and lastName, which can be accessed by calling getFirstName and getLastName respectively on the jobPurchaser object.

I can retrieve the first jobPurchaser object in the Collection by using $F{jobPurchaserCollection}.iterator().next() in my expression and I can get the first and last names by adding .getPurchaser().get____Name(). However, the problem is that subsequent calls to .iterator().next() within the expression all retrun the same value (ie. the first object in the collection). I want to be able to advance the iterator to the next object so that I can create a list of purchasers with firstName and lastName.

How can I do this in Jasper. I'm struggling to figure it out. I need an expression that will iterate through jobPurchaserCollection and get the first and last names of each purchaser. It doesn't appear that standarad Java loops work inside of the expression editior.

I'd very much appreciate the insights of someone more experienced than myself.

bls61793's picture
Joined: Jan 30 2017 - 11:57am
Last seen: 5 years 7 months ago

0 Answers:

No answers yet
Feedback
randomness