0

I am generating the source for af:image on runtime. Sometimes, when a source path is generated at runtime, there is no image at that source path. So in that case shortDesc field of that image is displayed instead. Is there a way to catch the exception (if thrown any) in that case and a default image can be shown instead.

aamadmi
  • 2,680
  • 2
  • 18
  • 21

2 Answers2

1

I faced a similar problem before and one solution I could come up with is providing a CSS background fallback, that way you can have default picture in case there is no image at the destination

Amr Gawish
  • 2,015
  • 1
  • 17
  • 29
  • Is there no way to check the validity of a URI. – aamadmi Apr 03 '12 at 09:04
  • You can do that by making Internet call using servlet or something and if it has 404 you can load another source, I just wanted to give you a quick solution without the need to write any external java code – Amr Gawish Apr 03 '12 at 11:01
0

This is possible using javascript. The img element has an onerror event which you can listen to.

Example:

<img src="idontexist.jpg" onerror="handleMissingImg" />

The only problem is that ADF does not expose that attribute for the image tag.

See How to silently hide "Image not found" icon when src source image is not found

Community
  • 1
  • 1
Hyangelo
  • 4,784
  • 4
  • 26
  • 33