JSF 2 GraphicImage Example

JavaServer Faces (JSF 2) provides a number of user interfaces components that cover the most common requirements, one of the most important component is a <h:graphicImage/> component. The graphicImage component renders an HTML image tag. This tag renders the HTML “img” element. If you are looking for the configuration of complete application, please read our JSF 2 Setup Tutorial.

Also Read:

1. The Views

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="http://www.w3.org/1999/xhtml"
	<h:graphicImage value="/resources/images/jvmhost.png" width="80px" height="80px"/>
  • The graphicImage component accept a value that reference the path of an image.
  • The image that the graphicImage referenced is located under resources/images folder.

2. Images Folder

In the JSF 2 application you have the ability to add an images folder under the context root of your web application. The below snapshot will show you the real location of the images that being used.

JSF 2 GraphicImage Example 1

3. JSF 2 GraphicImage Demo

The below snapshot will show you a running sample of GraphicImage example.

JSF 2 GraphicImage Example 2

Leave a Reply

Your email address will not be published. Required fields are marked *

Pin It on Pinterest

Share This

Share this post with your friends!