I am trying to generate a Jasper Report for an Invoice entity of mine.
Is there a way to change the view of the entity when it is selected?
What I have tried is: (will show photos)
Making the Invoice a required selection parameter.
Adding the invoice as a band so I can set the view:
Adding another band of groovy type to extract the values from the invoice entity
If you look at the third picture. I am trying to get i.e. invoice.contract.account.name
It does work, however the report creates two pages, one with null data and one with the correct data.
See attached PDF of the output I am gettingBlank_A4.pdf (11.8 KB)
Hi,
Yes, you are using the expected approach - just reload the entity in a Groovy band.
The only note: you are using low-level API with Persistence and EntityManager where it’s not necessary.
The better way is to use DataManager (use DataManager.reload(entity, viewName) method).
Can you add a second band that supplies fields to the Jasper Report? I have tried this but the report does not recognize the fields in subsequent bands.
If so, is is possible to use the parameters (fields) from a higher order band in a lower band query?
Is it only possible to use groovy dataset types to send to the report? Actually I suppose that is obvious as the report wouldn’t know about e.g. my Invoice.class - or can you send it as an object or something? i.e. can you send entities, sql, jpql etc to the JR?