0

I have tried everything I could in order to render simple image using h:graphicImage in template client. My image is not inside war but on another location on the same disk.

Actually I don't have 'alt' attribute displayed or warning that image cannot be found. My image is found and probably is rendered BUT as empty frame with width and height I specified in h:graphicImage. This empty frame has color of background.

Does anybody know how to render image from outer location as I have not found example of this?

Thank you!

0

1 Answer 1

1

The easiest way is to use OmniFaces o:graphicImage. Make a javax.faces.bean.ApplicationScoped bean with method which accepts path of file from filesystem and returns java.io.InputStream. Like that:

JAVA:

@Named @ApplicationScoped public class FileReader { public InputStream getImageByPath(String filename) throws FileNotFoundException{ return new FileInputStream(new File(filename)); } 

}

JSF:

<html xmlns:o="http://omnifaces.org/ui"> <o:graphicImage value="#{fileReader.getImageByPath('/opt/images/admin/112/IMG_1292.JPG')}"/> 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.