Search code examples
javaexpressionbirt

How can I embed images into a Birt report to show an image depending on if the column result equals 1 or 0?


How can I embed images into a Birt report to show images depending on if the result equals 1 or 0?

I’ve tried following the guide from:

http://birtworld.blogspot.com/2010/09/birt-image-report-item.html

I am not able to show an image (checkbox) when the column value equals 1 and another image (unchecked box) when the column value equals 0.

I’ve tried using the following expression:

if( row["acceptsplititem"] == 1 ){
"checked-50x49.jpg";
}else if( row["acceptsplititem"] == 0 ){
"unchecked-50x49.jpg";
}

I’ve tried adding both images (checked and unchecked) by dragging the image report item and selecting from image file in shared resources, then editing the URL of the image via: Properties > Advanced > URL

if( row["acceptsplititem"] == 1 ){
"checked-50x49.jpg";
}else if( row["acceptsplititem"] == 0 ){
"unchecked-50x49.jpg";
}

I’ve also tried a suggestion from a previous question/answer on stackoverflow:

Embedding an image in BIRT

But this doesn’t display either image.

Adding an image using Dynamic text

Embedding an image

Please help and advise where I am making a mistake

Thanks in advance,

Stuart


Solution

  • I've found that by inserting an image then selecting visibility from the Property Editor you can then tick Hide Element and enter an expression:

    row["preferred"]==0 
    

    This would hide the element (Tick Box) if the result is 0 Place another image (Crossed Box) on the same row with expression:

    row["preferred"]==1 
    

    This will hide the image if the result is 1