printWhenExpression on elements near by crosstab

Hi everyone!

I've got a text field on page header, a text field on page footer and a crosstab on report footer.
I need to print page header on first page of report and page footer on the rest pages. So I usualy use property 'print when expresson' that include next expression: '$V{PAGE_NUMBER} == 1' or '$V{PAGE_NUMBER} > 1'
But after adding crosstab on template I've got next error on generating report:

net.sf.jasperreports.engine.JRException: net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression for source text: $V{PAGE_NUMBER} == 1
Caused by: net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression for source text: $V{PAGE_NUMBER} == 1
    at net.sf.jasperreports.engine.fill.JREvaluator.handleEvaluationException(
    at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(
    at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(
    at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(
    at net.sf.jasperreports.engine.fill.JRFillDataset.evaluateExpression(
    at net.sf.jasperreports.engine.fill.BaseReportFiller.evaluateExpression(
    at net.sf.jasperreports.engine.fill.JRFillBand.evaluatePrintWhenExpression(
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillPageHeader(
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(
    at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(
    at net.sf.jasperreports.engine.fill.BaseFillHandle$
Caused by: java.lang.UnsupportedOperationException
    at net.sf.jasperreports.compilers.DirectEvaluator.evaluate(
    at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(
    ... 11 more

What I have to do to solve this problem?

P.S. if use only boolean value on band or text field then report will be generate correct

kuzkir89's picture
Joined: Nov 18 2015 - 1:25am
Last seen: 1 year 2 weeks ago

Could you please attach jrxml file instead of jasper?

alfpunk - 2 years 7 months ago

file attached

kuzkir89 - 2 years 7 months ago

1 Answer:


I investigate a little you jrxml.

  1. You want to see your "Page Header" only on the first report page, so for this, you use the boolean expression. Instead of this overhead, you could use "Title" - it's displayed only on the first page.
  2. The main information in report display in the "Detail". So, my suggestion is to remove "Group Header" and "Group Footer". Create in "Detail" element list. This list element will contain:
    1. frame (if you need some 50px between header and crosstab, as you did via "Detail" just create this frame height 69px)
      1. with staticText Transportnoe predprijatie:
      2. and textField $F{parkTitle}
    2. list
      1. Crosstab

​​​​​​​​​​​​​​I can't locally reproduce your error, possibly something is wrong in crosstab element.


alfpunk's picture
Joined: Apr 30 2020 - 1:04am
Last seen: 1 year 6 months ago