jsf

GraphicImage Example with JSF 2.0

Hi there, pretty short time since my last example! This one is gonna be too short, ’cause you ‘re now enough experienced to get the best out of it.

Assuming that we ‘re building an awesome web application and we want to include an image or more in it, here comes the question: how could we get this done?
 
 
 
 
 
 
 

 
In JSF, we can use the <h:graphicImage /> tag to render an HTML img element. The approved way of including images in our application, is placing them under the webapp and especially in a structure like below:

img

1. JSF 1.x graphicImage

According to JSF 1.x, we could hardcode the relative path directly as a value attribute:

<h:graphicImage value="resources/images/JCG_watermark.png" />

, which generates the following HTML output:

<img src="resources/images/JCG_watermark.png;" alt="" />

2. JSF 2.x graphicImage

According to JSF 2.x, we can render an image like this:

<h:graphicImage library="images" name="JCG_watermark.png" />

So, that was it for today!
This was an example of GraphicImage in JSF 2.0.

Thodoris Bais

Thodoris is an Oracle Certified Associate Java Programmer and currently works as a Junior Software Developer, for Intrasoft International S.A. He holds a diploma at Informatics & Telecommunications Engineering and is interested in continuous development.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments
Back to top button