title: How to add chart in pageheader by JasperReports java API?
body: <p>At first, I create a chart, and set a <code>CustomizerClass</code> to it. I use <code>setNoDataMessage</code> in the <code>customizerClass</code> to check that if any data is selected from database. The chart works fine in summary, but the <code>NoDataMessage</code> shows up when I put the chart in pageheader. </p>
  
  <p>Does anyone have any ideas on this problem?</p>
  
  <p>PS. The chart also works fine in footer、detail. The <code>NoDataMessage</code> shows up in title、pageheader、columnheader.</p>
  
  <p>The jrxml file, exported by  <code>JasperReports java API</code>, is shown below.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Sample3Report" pageWidth="700" pageHeight="3000" whenNoDataType="AllSectionsNoDetail" columnWidth="562" leftMargin="30" rightMargin="20" topMargin="30" bottomMargin="30" isTitleNewPage="true" isSummaryNewPage="true"&gt;
      &lt;style name="titleStyle" isDefault="true" forecolor="#000000" fontName="Helvetica" fontSize="20" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" isPdfEmbedded="true"/&gt;
      &lt;style name="headerStyle" isDefault="true" forecolor="#FFFFFF" backcolor="#808080" fontName="Helvetica" fontSize="12" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" isPdfEmbedded="true"/&gt;
      &lt;style name="detailStyle" isDefault="true" forecolor="#000000" fontName="Helvetica" fontSize="12" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" isPdfEmbedded="true"/&gt;
      &lt;style name="pageheaderStyle" isDefault="true" forecolor="#000000" fontName="Helvetica" fontSize="10" isItalic="false" isUnderline="false" isStrikeThrough="false" isPdfEmbedded="true"/&gt;
      &lt;parameter name="IMAGE" class="java.lang.String"/&gt;
      &lt;queryString&gt;
          &lt;![CDATA[select p.personid as personId, p.name as personName, p.age as personAge, c.carid as carId, c.model as carModel, c.color as carColor, c.price as carPrice from person p join car c on p.personid=c.ownerid order by personName]]&gt;
      &lt;/queryString&gt;
      &lt;field name="personName" class="java.lang.String"/&gt;
      &lt;field name="personAge" class="java.lang.Integer"/&gt;
      &lt;field name="carModel" class="java.lang.String"/&gt;
      &lt;field name="carColor" class="java.lang.String"/&gt;
      &lt;field name="carPrice" class="java.lang.Integer"/&gt;
      &lt;title&gt;
          &lt;band height="700"&gt;
              &lt;textField isStretchWithOverflow="true" isBlankWhenNull="true"&gt;
                  &lt;reportElement key="titleTextField" style="titleStyle" positionType="Float" stretchType="RelativeToTallestObject" mode="Opaque" x="0" y="250" width="600" height="300"/&gt;
                  &lt;box padding="1"&gt;
                      &lt;pen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/&gt;
                  &lt;/box&gt;
                  &lt;textElement textAlignment="Center"/&gt;
                  &lt;textFieldExpression class="java.lang.String"&gt;&lt;![CDATA["Cars report"+"\n\n.subtitle"+"\n\n.writer"]]&gt;&lt;/textFieldExpression&gt;
              &lt;/textField&gt;
          &lt;/band&gt;
      &lt;/title&gt;
      &lt;pageHeader&gt;
          &lt;band height="500"&gt;
              &lt;textField isStretchWithOverflow="true" evaluationTime="Auto" isBlankWhenNull="true"&gt;
                  &lt;reportElement key="titleTextField" style="detailStyle" positionType="Float" stretchType="RelativeToTallestObject" mode="Opaque" x="570" y="0" width="600" height="14"/&gt;
                  &lt;box padding="1"&gt;
                      &lt;pen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/&gt;
                  &lt;/box&gt;
                  &lt;textElement textAlignment="Left"/&gt;
                  &lt;textFieldExpression class="java.lang.String"&gt;&lt;![CDATA["Cars table"]]&gt;&lt;/textFieldExpression&gt;
              &lt;/textField&gt;
              &lt;image&gt;
                  &lt;reportElement x="540" y="0" width="30" height="30"/&gt;
                  &lt;imageExpression class="java.lang.String"&gt;&lt;![CDATA["http://static4.depositphotos.com/1029305/388/v/950/depositphotos_3889034-Stylized-cartoon-car.jpg"]]&gt;&lt;/imageExpression&gt;
              &lt;/image&gt;
              &lt;areaChart&gt;
                  &lt;chart customizerClass="customizer.AreaChartCustomizer"&gt;
                      &lt;reportElement x="0" y="100" width="350" height="200"/&gt;
                      &lt;chartTitle&gt;
                          &lt;titleExpression&gt;&lt;![CDATA["chart1. line chart of portA"]]&gt;&lt;/titleExpression&gt;
                      &lt;/chartTitle&gt;
                      &lt;chartSubtitle/&gt;
                      &lt;chartLegend/&gt;
                  &lt;/chart&gt;
                  &lt;categoryDataset&gt;
                      &lt;categorySeries&gt;
                          &lt;seriesExpression&gt;&lt;![CDATA["test"]]&gt;&lt;/seriesExpression&gt;
                          &lt;categoryExpression&gt;&lt;![CDATA[$F{carModel}]]&gt;&lt;/categoryExpression&gt;
                          &lt;valueExpression&gt;&lt;![CDATA[$F{carPrice}]]&gt;&lt;/valueExpression&gt;
                      &lt;/categorySeries&gt;
                  &lt;/categoryDataset&gt;
                  &lt;areaPlot&gt;
                      &lt;plot/&gt;
                      &lt;categoryAxisFormat&gt;
                          &lt;axisFormat&gt;
                              &lt;labelFont/&gt;
                              &lt;tickLabelFont/&gt;
                          &lt;/axisFormat&gt;
                      &lt;/categoryAxisFormat&gt;
                      &lt;valueAxisFormat&gt;
                          &lt;axisFormat&gt;
                              &lt;labelFont/&gt;
                              &lt;tickLabelFont/&gt;
                          &lt;/axisFormat&gt;
                      &lt;/valueAxisFormat&gt;
                  &lt;/areaPlot&gt;
              &lt;/areaChart&gt;
          &lt;/band&gt;
      &lt;/pageHeader&gt;
      &lt;columnHeader&gt;
          &lt;band height="12"&gt;
              &lt;textField isStretchWithOverflow="true" isBlankWhenNull="true"&gt;
                  &lt;reportElement key="headerField1" style="headerStyle" positionType="Float" stretchType="RelativeToTallestObject" mode="Opaque" x="0" y="0" width="150" height="12"/&gt;
                  &lt;box padding="2"&gt;
                      &lt;pen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/&gt;
                  &lt;/box&gt;
                  &lt;textElement textAlignment="Center"/&gt;
                  &lt;textFieldExpression class="java.lang.String"&gt;&lt;![CDATA["Owner name"]]&gt;&lt;/textFieldExpression&gt;
              &lt;/textField&gt;
              &lt;textField isStretchWithOverflow="true" isBlankWhenNull="true"&gt;
                  &lt;reportElement key="headerField2" style="headerStyle" positionType="Float" stretchType="RelativeToTallestObject" mode="Opaque" x="150" y="0" width="100" height="12"/&gt;
                  &lt;box padding="2"&gt;
                      &lt;pen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/&gt;
                  &lt;/box&gt;
                  &lt;textElement textAlignment="Center"/&gt;
                  &lt;textFieldExpression class="java.lang.String"&gt;&lt;![CDATA["Owner age"]]&gt;&lt;/textFieldExpression&gt;
              &lt;/textField&gt;
              &lt;textField isStretchWithOverflow="true" isBlankWhenNull="true"&gt;
                  &lt;reportElement key="headerField3" style="headerStyle" positionType="Float" stretchType="RelativeToTallestObject" mode="Opaque" x="250" y="0" width="150" height="12"/&gt;
                  &lt;box padding="2"&gt;
                      &lt;pen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/&gt;
                  &lt;/box&gt;
                  &lt;textElement textAlignment="Center"/&gt;
                  &lt;textFieldExpression class="java.lang.String"&gt;&lt;![CDATA["Car model"]]&gt;&lt;/textFieldExpression&gt;
              &lt;/textField&gt;
              &lt;textField isStretchWithOverflow="true" isBlankWhenNull="true"&gt;
                  &lt;reportElement key="headerField4" style="headerStyle" positionType="Float" stretchType="RelativeToTallestObject" mode="Opaque" x="400" y="0" width="100" height="12"/&gt;
                  &lt;box padding="2"&gt;
                      &lt;pen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/&gt;
                  &lt;/box&gt;
                  &lt;textElement textAlignment="Center"/&gt;
                  &lt;textFieldExpression class="java.lang.String"&gt;&lt;![CDATA["Car color"]]&gt;&lt;/textFieldExpression&gt;
              &lt;/textField&gt;
              &lt;textField isStretchWithOverflow="true" isBlankWhenNull="true"&gt;
                  &lt;reportElement key="headerField5" style="headerStyle" positionType="Float" stretchType="RelativeToTallestObject" mode="Opaque" x="500" y="0" width="100" height="12"/&gt;
                  &lt;box padding="2"&gt;
                      &lt;pen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/&gt;
                  &lt;/box&gt;
                  &lt;textElement textAlignment="Center"/&gt;
                  &lt;textFieldExpression class="java.lang.String"&gt;&lt;![CDATA["Car price"]]&gt;&lt;/textFieldExpression&gt;
              &lt;/textField&gt;
          &lt;/band&gt;
      &lt;/columnHeader&gt;
      &lt;detail&gt;
          &lt;band height="12"&gt;
              &lt;textField isStretchWithOverflow="true" isBlankWhenNull="true"&gt;
                  &lt;reportElement key="detailField1" style="detailStyle" positionType="Float" stretchType="RelativeToTallestObject" mode="Opaque" x="0" y="0" width="150" height="12"/&gt;
                  &lt;box padding="2"&gt;
                      &lt;pen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/&gt;
                  &lt;/box&gt;
                  &lt;textElement textAlignment="Left"/&gt;
                  &lt;textFieldExpression class="java.lang.String"&gt;&lt;![CDATA[$F{personName}]]&gt;&lt;/textFieldExpression&gt;
              &lt;/textField&gt;
              &lt;textField isStretchWithOverflow="true" isBlankWhenNull="true"&gt;
                  &lt;reportElement key="detailField2" style="detailStyle" positionType="Float" stretchType="RelativeToTallestObject" mode="Opaque" x="150" y="0" width="100" height="12"/&gt;
                  &lt;box padding="2"&gt;
                      &lt;pen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/&gt;
                  &lt;/box&gt;
                  &lt;textElement textAlignment="Right"/&gt;
                  &lt;textFieldExpression class="java.lang.Integer"&gt;&lt;![CDATA[$F{personAge}]]&gt;&lt;/textFieldExpression&gt;
              &lt;/textField&gt;
              &lt;textField isStretchWithOverflow="true" isBlankWhenNull="true"&gt;
                  &lt;reportElement key="detailField3" style="detailStyle" positionType="Float" stretchType="RelativeToTallestObject" mode="Opaque" x="250" y="0" width="150" height="12"/&gt;
                  &lt;box padding="2"&gt;
                      &lt;pen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/&gt;
                  &lt;/box&gt;
                  &lt;textElement textAlignment="Left"/&gt;
                  &lt;textFieldExpression class="java.lang.String"&gt;&lt;![CDATA[$F{carModel}]]&gt;&lt;/textFieldExpression&gt;
              &lt;/textField&gt;
              &lt;textField isStretchWithOverflow="true" isBlankWhenNull="true"&gt;
                  &lt;reportElement key="detailField4" style="detailStyle" positionType="Float" stretchType="RelativeToTallestObject" mode="Opaque" x="400" y="0" width="100" height="12"/&gt;
                  &lt;box padding="2"&gt;
                      &lt;pen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/&gt;
                  &lt;/box&gt;
                  &lt;textElement textAlignment="Left"/&gt;
                  &lt;textFieldExpression class="java.lang.String"&gt;&lt;![CDATA[$F{carColor}]]&gt;&lt;/textFieldExpression&gt;
              &lt;/textField&gt;
              &lt;textField isStretchWithOverflow="true" isBlankWhenNull="true"&gt;
                  &lt;reportElement key="detailField5" style="detailStyle" positionType="Float" stretchType="RelativeToTallestObject" mode="Opaque" x="500" y="0" width="100" height="12"/&gt;
                  &lt;box padding="2"&gt;
                      &lt;pen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/&gt;
                  &lt;/box&gt;
                  &lt;textElement textAlignment="Left"/&gt;
                  &lt;textFieldExpression class="java.lang.Integer"&gt;&lt;![CDATA[$F{carPrice}]]&gt;&lt;/textFieldExpression&gt;
              &lt;/textField&gt;
          &lt;/band&gt;
      &lt;/detail&gt;
      &lt;pageFooter&gt;
          &lt;band height="50"&gt;
              &lt;textField isStretchWithOverflow="true" isBlankWhenNull="true"&gt;
                  &lt;reportElement key="titleTextField" style="pageheaderStyle" positionType="Float" stretchType="RelativeToTallestObject" mode="Opaque" x="30" y="0" width="600" height="14"/&gt;
                  &lt;box padding="1"&gt;
                      &lt;pen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/&gt;
                  &lt;/box&gt;
                  &lt;textElement textAlignment="Left"/&gt;
                  &lt;textFieldExpression class="java.lang.String"&gt;&lt;![CDATA["Cars table"]]&gt;&lt;/textFieldExpression&gt;
              &lt;/textField&gt;
              &lt;image&gt;
                  &lt;reportElement x="0" y="0" width="50" height="50"/&gt;
                  &lt;imageExpression class="java.lang.String"&gt;&lt;![CDATA[$P{IMAGE}]]&gt;&lt;/imageExpression&gt;
              &lt;/image&gt;
          &lt;/band&gt;
      &lt;/pageFooter&gt;
      &lt;summary&gt;
          &lt;band height="700"&gt;
              &lt;lineChart&gt;
                  &lt;chart isShowLegend="true"&gt;
                      &lt;reportElement x="0" y="300" width="350" height="200"/&gt;
                      &lt;chartTitle&gt;
                          &lt;titleExpression&gt;&lt;![CDATA["chart2. line chart of portB"]]&gt;&lt;/titleExpression&gt;
                      &lt;/chartTitle&gt;
                      &lt;chartSubtitle/&gt;
                      &lt;chartLegend textColor="#FFFF00" backgroundColor="#0000FF"/&gt;
                  &lt;/chart&gt;
                  &lt;categoryDataset&gt;
                      &lt;categorySeries&gt;
                          &lt;seriesExpression&gt;&lt;![CDATA["test"]]&gt;&lt;/seriesExpression&gt;
                          &lt;categoryExpression&gt;&lt;![CDATA[$F{carModel}]]&gt;&lt;/categoryExpression&gt;
                          &lt;valueExpression&gt;&lt;![CDATA[$F{carPrice}]]&gt;&lt;/valueExpression&gt;
                      &lt;/categorySeries&gt;
                  &lt;/categoryDataset&gt;
                  &lt;linePlot&gt;
                      &lt;plot/&gt;
                      &lt;categoryAxisFormat&gt;
                          &lt;axisFormat&gt;
                              &lt;labelFont/&gt;
                              &lt;tickLabelFont/&gt;
                          &lt;/axisFormat&gt;
                      &lt;/categoryAxisFormat&gt;
                      &lt;valueAxisFormat&gt;
                          &lt;axisFormat&gt;
                              &lt;labelFont/&gt;
                              &lt;tickLabelFont/&gt;
                          &lt;/axisFormat&gt;
                      &lt;/valueAxisFormat&gt;
                  &lt;/linePlot&gt;
              &lt;/lineChart&gt;
              &lt;areaChart&gt;
                  &lt;chart customizerClass="customizer.AreaChartCustomizer"&gt;
                      &lt;reportElement x="0" y="100" width="350" height="200"/&gt;
                      &lt;chartTitle&gt;
                          &lt;titleExpression&gt;&lt;![CDATA["chart1. line chart of portA"]]&gt;&lt;/titleExpression&gt;
                      &lt;/chartTitle&gt;
                      &lt;chartSubtitle/&gt;
                      &lt;chartLegend/&gt;
                  &lt;/chart&gt;
                  &lt;categoryDataset&gt;
                      &lt;categorySeries&gt;
                          &lt;seriesExpression&gt;&lt;![CDATA["test"]]&gt;&lt;/seriesExpression&gt;
                          &lt;categoryExpression&gt;&lt;![CDATA[$F{carModel}]]&gt;&lt;/categoryExpression&gt;
                          &lt;valueExpression&gt;&lt;![CDATA[$F{carPrice}]]&gt;&lt;/valueExpression&gt;
                      &lt;/categorySeries&gt;
                  &lt;/categoryDataset&gt;
                  &lt;areaPlot&gt;
                      &lt;plot/&gt;
                      &lt;categoryAxisFormat&gt;
                          &lt;axisFormat&gt;
                              &lt;labelFont/&gt;
                              &lt;tickLabelFont/&gt;
                          &lt;/axisFormat&gt;
                      &lt;/categoryAxisFormat&gt;
                      &lt;valueAxisFormat&gt;
                          &lt;axisFormat&gt;
                              &lt;labelFont/&gt;
                              &lt;tickLabelFont/&gt;
                          &lt;/axisFormat&gt;
                      &lt;/valueAxisFormat&gt;
                  &lt;/areaPlot&gt;
              &lt;/areaChart&gt;
              &lt;multiAxisChart&gt;
                  &lt;chart customizerClass="customizer.MultiAxisOrderCustomizer"&gt;
                      &lt;reportElement x="0" y="500" width="350" height="200"/&gt;
                      &lt;chartTitle/&gt;
                      &lt;chartSubtitle/&gt;
                      &lt;chartLegend/&gt;
                  &lt;/chart&gt;
                  &lt;multiAxisPlot&gt;
                      &lt;plot/&gt;
                      &lt;axis&gt;
                          &lt;areaChart&gt;
                              &lt;chart customizerClass="customizer.AreaChartCustomizer"&gt;
                                  &lt;reportElement x="0" y="100" width="350" height="200" backcolor="#FFFFFF"/&gt;
                                  &lt;chartTitle color="#000000"/&gt;
                                  &lt;chartSubtitle color="#000000"/&gt;
                                  &lt;chartLegend textColor="#000000" backgroundColor="#FFFFFF"/&gt;
                              &lt;/chart&gt;
                              &lt;categoryDataset&gt;
                                  &lt;categorySeries&gt;
                                      &lt;seriesExpression&gt;&lt;![CDATA["test"]]&gt;&lt;/seriesExpression&gt;
                                      &lt;categoryExpression&gt;&lt;![CDATA[$F{carModel}]]&gt;&lt;/categoryExpression&gt;
                                      &lt;valueExpression&gt;&lt;![CDATA[$F{carPrice}]]&gt;&lt;/valueExpression&gt;
                                  &lt;/categorySeries&gt;
                              &lt;/categoryDataset&gt;
                              &lt;areaPlot&gt;
                                  &lt;plot/&gt;
                                  &lt;categoryAxisFormat&gt;
                                      &lt;axisFormat&gt;
                                          &lt;labelFont/&gt;
                                          &lt;tickLabelFont/&gt;
                                      &lt;/axisFormat&gt;
                                  &lt;/categoryAxisFormat&gt;
                                  &lt;valueAxisFormat&gt;
                                      &lt;axisFormat&gt;
                                          &lt;labelFont/&gt;
                                          &lt;tickLabelFont/&gt;
                                      &lt;/axisFormat&gt;
                                  &lt;/valueAxisFormat&gt;
                              &lt;/areaPlot&gt;
                          &lt;/areaChart&gt;
                      &lt;/axis&gt;
                      &lt;axis&gt;
                          &lt;lineChart&gt;
                              &lt;chart&gt;
                                  &lt;reportElement x="0" y="300" width="350" height="200" backcolor="#FFFFFF"/&gt;
                                  &lt;chartTitle color="#000000"/&gt;
                                  &lt;chartSubtitle color="#000000"/&gt;
                                  &lt;chartLegend textColor="#000000" backgroundColor="#FFFFFF"/&gt;
                              &lt;/chart&gt;
                              &lt;categoryDataset&gt;
                                  &lt;categorySeries&gt;
                                      &lt;seriesExpression&gt;&lt;![CDATA["test"]]&gt;&lt;/seriesExpression&gt;
                                      &lt;categoryExpression&gt;&lt;![CDATA[$F{carModel}]]&gt;&lt;/categoryExpression&gt;
                                      &lt;valueExpression&gt;&lt;![CDATA[$F{carPrice}]]&gt;&lt;/valueExpression&gt;
                                  &lt;/categorySeries&gt;
                              &lt;/categoryDataset&gt;
                              &lt;linePlot&gt;
                                  &lt;plot/&gt;
                                  &lt;categoryAxisFormat&gt;
                                      &lt;axisFormat&gt;
                                          &lt;labelFont/&gt;
                                          &lt;tickLabelFont/&gt;
                                      &lt;/axisFormat&gt;
                                  &lt;/categoryAxisFormat&gt;
                                  &lt;valueAxisFormat&gt;
                                      &lt;axisFormat&gt;
                                          &lt;labelFont/&gt;
                                          &lt;tickLabelFont/&gt;
                                      &lt;/axisFormat&gt;
                                  &lt;/valueAxisFormat&gt;
                              &lt;/linePlot&gt;
                          &lt;/lineChart&gt;
                      &lt;/axis&gt;
                  &lt;/multiAxisPlot&gt;
              &lt;/multiAxisChart&gt;
          &lt;/band&gt;
      &lt;/summary&gt;
  &lt;/jasperReport&gt;
  </code></pre>