Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
How to hide an image if the path does not exist.
claudiap
Hello.
I have to display an image from the shared resorces ( I give its path). If the image exists, everything looks fine, but if not, there appears a text with the "image not reachable" message in the generated report(see atachment)
Find more posts tagged with
Comments
JasonW
Is the image in the resource folder or is the path a full url. If it is in the resource folder you could try something like reportContext.getResource("imagename"); Then check this value for null. If the image is a url you could try something like:
valid_url=true;
importPackage(Packages.java.net);
try {
url = new URL("urltoimage");
input = url.openStream();
input.close();
} catch (e) {
valid_url = false;
}
Jason
claudiap
Thank you Jason, this really helped.
uttambirt
<p>Hi Janson , iam using URI , but your code for visibility is not working</p>
pricher
<p>Hi,</p>
<p> </p>
<p>I got the code working, but you may want to consider a couple of things:</p>
<p> </p>
<p>1. If you are running your report from BIRT Designer, make sure the URL (specifically the image filename) does not contain spaces. There is an issue with Tomcat where creating a URL with a space. So, you need to replace spaces with the proper encoding, %20.</p>
<p> </p>
<p>2. The code does not run when scripted in the image component. In the attached example, I have added the code to the report's beforeFactory. The result is saved in a global variable. I test the value of that variable in the image Visibility property.</p>
<p> </p>
<p>Hope this helps,</p>
<p> </p>
<p>P.</p>
aparna.r.gururani
<p>Thanks Jason,</p>
<p>It really Helped.</p>