I have a graphicImage that takes its value from a servlet (called "picture" - it dynamically serves images stored on the server).
I would like to hide graphicImage when servlet returns null (no image was found). I tried using FacesContext.getCurrentInstance().getExternalContext().getResource() but it returns null even for correct URLs.
<h:graphicImage value="/picture?name=#{myBean.name}" />
if i missunderstand you then sorry.
i would suggest two ways to hide this image:
you can check in any ControllerBean (myBean, or ...) if that image exists or not, and passing a rendered Property to JSF UI:
<h:graphicImage value="/picture?name=#{myBean.name}" rendered="pictureControler.isFound"/>
or just add alt="" to that image, this image woun't be displayed then.
<h:graphicImage value="/picture?name=#{myBean.name}" alt=" "/>
NOTE: the last one not tested but i think should work.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.