Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Dynamic image in table column
cornholio002
<p>Hi!</p>
<p> </p>
<p>I have an xml datasource with many items with the same type. One item contains simple string attributes and an icon as base64 encoded string.</p>
<p>I've built a table from this item list dataset. Every attribute appears correctly except the image. It is the same for all rows (always the one from the first row).</p>
<p> </p>
<p>I use on create method to decode the base64 string to byte[]:</p>
<div> <cell id="548"></div>
<div> <image id="802"></div>
<div> <property name="dataSet">Transactions</property></div>
<div> <list-property name="boundDataColumns"></div>
<div> <structure></div>
<div> <property name="name">CategoryIcon</property></div>
<div> <expression name="expression" type="javascript">dataSetRow["CategoryIcon"]</expression></div>
<div> <property name="dataType">string</property></div>
<div> </structure></div>
<div> </list-property></div>
<div> <method name="onCreate"><![CDATA[</div>
<div>importPackage(Packages.javax.imageio);</div>
<div>importPackage(Packages.java.io);</div>
<div>importPackage(Packages.org.apache.commons.codec.binary)</div>
<div>importPackage(Packages.java.lang);</div>
<div> </div>
<div>decodedBytes = Base64.decodeBase64(this.getRowData().getColumnValue("CategoryIcon").getBytes());</div>
<div>this.data = decodedBytes;</div>
<div>bais = new ByteArrayInputStream( decodedBytes);</div>
<div>bufimg = ImageIO.read(bais);</div>
<div>this.setHeight(bufimg.getHeight() +"px");</div>
<div>this.setWidth(bufimg.getWidth() +"px");</div>
<div> ]]></method></div>
<div> <property name="source">expr</property></div>
<div> <expression name="valueExpr">row["CategoryIcon"]</expression></div>
<div> </image></div>
<div> </cell></div>
<div> </div>
<div> </div>
<div>Could you help me, what could be the problem?</div>
<div> </div>
<div>My BIRT designer version is: Build id: 20140612-0600</div>
<div>The problem occurs also when I use the template from java code.</div>
<div> </div>
<div> </div>
Find more posts tagged with
Comments
micajblock
<p>Cab you provide a sample XML file?</p>
cornholio002
<p>Attached sample.
micajblock
<p>See attached example. Look at the onCreate event of the dynamic image report item.</p>
cornholio002
<p>Many thanks.</p>
<p> </p>
<p>I've left out the data bingind from table definition.</p>
<p> </p>
<p>Regards,</p>
<p>cornholio</p>
Devel Baghel
<p>Hi,</p>
<p> </p>
<p>I also have an issue with the dynamic image. I have a byte array column which i am binding to the image control but it is showing an error at runtime as "The resource of this report item is not reachable". Can anyone please help me, how to achieve this functionality to display the dynamic image on report....</p>
micajblock
<p>can you reproduce with something we can run?</p>