I am trying to print the last record of the group but the expression "print when group changes: True" does not seem to work. It simply prints all the records of that group. (I've grouped the record based on username).
I've never used the 'print when group changes' functionality, but trying it now on a new report, I see what you mean - it prints for every detail record even though the group is not changing.
Instead of using the 'print when group changes' flag, uncheck the 'print repeated values' flag, this will probably give you what you want.
I was having trouble with the same issue. Here is the work around that I came up with:
JasperReports has some automatically generated variables that may help you achieve what you want. For every group you create there is a counter that keeps track of the number of items in your current group:
yourGroupName_COUNT
In your printWhenExpression simply add an expression like the following to only print the textfield when your group ruptures:
$V{yourGroupName_COUNT}==1
-Benjamin
I don't think that attribute is doing what you think it does. It's supposed to be used in conjunction with isPrintRepeatedValues="false" and works the following way:
"if the repeating value you have suppressed spans multiple groups, you can make it reappear at the beginning of a certain report group if you specify the name of that particular group in the printWhenGroupChanges attribute." Ultimate Guide pg. 116