title: Hide image when its value is NULL or Empty in JasperReports
body: <p>I am using JasperReports 6.2.2 version. I want to hide image if the value is null or empty.</p>
  
  <p>Below code I used in jrxml to hide the image, but this doesn't work for me.</p>
  
  <pre><code>&lt;image&gt;
      &lt;reportElement x="33" y="0" width="88" height="45" uuid="182b40f8-b18e-417c-b9f4-096199533567"&gt;
          &lt;printWhenExpression&gt;&lt;![CDATA[($F{urlImage}!=null ? $F{urlImage} : "")]]&gt;&lt;/printWhenExpression&gt;
      &lt;/reportElement&gt;
  &lt;/image&gt;
  </code></pre>
  
  <p><strong>$F{urlImage} is of String type</strong></p>
  
  <p>It gives an error </p>
  
  <pre><code>ERROR [btpool0-2] (JRFillSubreport.java:866) - Fill 1: exception
       [java] java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Boolean
       [java]     at net.sf.jasperreports.engine.fill.JRFillElement.evaluatePrintWhenExpression(JRFillElement.java:806)
       [java]     at net.sf.jasperreports.engine.fill.JRFillImage.evaluate(JRFillImage.java:471)
       [java]     at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:381)
       [java]     at net.sf.jasperreports.engine.fill.JRFillFrame.evaluate(JRFillFrame.java:159)
       [java]     at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:381)
       [java]     at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:500)
       [java]     at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2022)
       [java]     at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:748)
       [java]     at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:255)
       [java] java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Boolean
       [java]     at net.sf.jasperreports.engine.fill.JRFillElement.evaluatePrintWhenExpression(JRFillElement.java:806)
       [java]     at net.sf.jasperreports.engine.fill.JRFillImage.evaluate(JRFillImage.java:471)
       [java]     at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:381)
       [java]     at net.sf.jasperreports.engine.fill.JRFillFrame.evaluate(JRFillFrame.java:159)
       [java]     at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:381)
       [java]     at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:500)
       [java]     at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2022)
       [java]     at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:748)
       [java]     at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:255)
       [java]     at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:115)
       [java]     at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:580)
       [java]     at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:414)
       [java]     at net.sf.jasperreports.engine.fill.JRFillSubreport.fillSubreport(JRFillSubreport.java:736)
       [java]     at net.sf.jasperreports.engine.fill.JRSubreportRunnable.run(JRSubreportRunnable.java:59)
       [java]     at net.sf.jasperreports.engine.fill.AbstractThreadSubreportRunner.run(AbstractThreadSubreportRunner.java:221)
       [java]     at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
       [java]     at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
       [java]     at java.lang.Thread.run(Unknown Source)
       [java]     at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:115)
       [java]     at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:580)
       [java]     at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:414)
       [java]     at net.sf.jasperreports.engine.fill.JRFillSubreport.fillSubreport(JRFillSubreport.java:736)
       [java]     at net.sf.jasperreports.engine.fill.JRSubreportRunnable.run(JRSubreportRunnable.java:59)
       [java]     at net.sf.jasperreports.engine.fill.AbstractThreadSubreportRunner.run(AbstractThreadSubreportRunner.java:221)
       [java]     at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
       [java]     at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
       [java]     at java.lang.Thread.run(Unknown Source)
  </code></pre>
  
  <p>How to hide the image if its value is null or empty. In urlImage field contains the url of the image. For example: "[<a href="http://use.example.com/pop.png][1]" rel="nofollow noreferrer">http://use.example.com/pop.png][1]</a>".</p>