TIBCOSoftware / jasperreports

JasperReports® - Free Java Reporting Library
https://community.jaspersoft.com/downloads/community-edition/
GNU Lesser General Public License v3.0
1.03k stars 397 forks source link

Group header/title band taking up at least a page leads to loss of variable values in specific cases. #418

Closed SofieStrumane closed 7 months ago

SofieStrumane commented 7 months ago

See added zip file. An issue in which a variable loses its value when a group header band or title band takes up a whole page in combination with Split Type of the following detail band being set to "Prevent". (We are currently working with version 6.20.3)

group header taking up at least a page leads to loss of variable values.jrxml.zip

teodord commented 7 months ago

I think it would be better if you could explain what kind of variable you want to use. Why do you need a variable that does not change value? You could use a parameter with defaultValueExpression instead.

SofieStrumane commented 7 months ago

Thanks for the reply Teodor! We did eventually fix it by using a parameter. In certain situations however, it is more difficult for us to go for parameters. When we make compositions it is often easier for us to work with variables that don't change instead of parameters as in the case of parameters we often have to introduce a whole lot of parameter bindings and it starts getting quite complex.

Either way, the variable losing its value just seemed like a bit strange behaviour so we wanted to mention it here. Yesplan has been working with JasperReports for 10+ years and we're very happy with it so we want to contribute to further helping it be as reliable as possible!

teodord commented 7 months ago

The case you described is indeed tricky and the reason I suggested you use a workaround is because I'm not sure we are going to try fix it as it is in a very delicate part of the program and any change would probably cause other regressions.

Using parameters with default value expression is in my opinion the best way for declaring "constant" values. There should be no difference between declaring a parameter or a variable with such behaviour. Not sure what you mean by "parameter binding", but parameters can simply be declared and used inside the current report/dataset, without being passed around.

SofieStrumane commented 6 months ago

Thanks for the explanation, we'll keep it in mind. Just as an afterthought so that you are fully up to date with this issue: We tested it using a variable that changes value (Say, an integer variable x with initial value "0" with expression $V{x}+1) and the problem is the same, namely the variable loses its value and prints "null". Our main issue with it is that the null pointer exception gets absorbed by the Jaspersoft Studio so we are often unaware of the issue until it gets pointed out by a client of ours that the value is not being printed as expected in the report.