Thodoris Bais

About Thodoris Bais

Thodoris Bais is currently working as a Junior Java Developer while on parallel, pursuing a diploma at Informatics & Telecommunications Engineering. He specializes in Java Core, Android and J2EE and looks forward to being a successfull professional. He is interested in entrepreneurship and is also a quick learner and curious about new technologies.

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.

Do you want to know how to develop your skillset to become a Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you two of our best selling eBooks for FREE!

JPA Mini Book

Learn how to leverage the power of JPA in order to create robust and flexible Java applications. With this Mini Book, you will get introduced to JPA and smoothly transition to more advanced concepts.

JVM Troubleshooting Guide

The Java virtual machine is really the foundation of any Java EE platform. Learn how to master it with this advanced guide!

Given email address is already subscribed, thank you!
Oops. Something went wrong. Please try again later.
Please provide a valid email address.
Thank you, your sign-up request was successful! Please check your e-mail inbox.
Please complete the CAPTCHA.
Please fill in the required fields.
Examples Java Code Geeks and all content copyright © 2010-2014, Exelixis Media Ltd | Terms of Use | Privacy Policy | Contact
All trademarks and registered trademarks appearing on Examples Java Code Geeks are the property of their respective owners.
Java is a trademark or registered trademark of Oracle Corporation in the United States and other countries.
Examples Java Code Geeks is not connected to Oracle Corporation and is not sponsored by Oracle Corporation.
Do you want to know how to develop your skillset and become a ...
Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you two of our best selling eBooks for FREE!

Get ready to Rock!
You can download the complementary eBooks using the links below:
Close