Jump to content

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


bls61793

Recommended Posts

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.

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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