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 professional Software Engineer. He 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.

Related Whitepaper:

Java Essential Training

Author David Gassner explores Java SE (Standard Edition), the language used to build mobile apps for Android devices, enterprise server applications, and more!

The course demonstrates how to install both Java and the Eclipse IDE and dives into the particulars of programming. The course also explains the fundamentals of Java, from creating simple variables, assigning values, and declaring methods to working with strings, arrays, and subclasses; reading and writing to text files; and implementing object oriented programming concepts. Exercise files are included with the course.

Get it Now!  

Examples Java Code Geeks and all content copyright © 2010-2014, Exelixis Media Ltd | Terms of Use | Privacy Policy
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.

Sign up for our Newsletter

20,709 insiders are already enjoying weekly updates and complimentary whitepapers! Join them now to gain exclusive access to the latest news in the Java world, as well as insights about Android, Scala, Groovy and other related technologies.

As an extra bonus, by joining you will get our brand new e-books, published by Java Code Geeks and their JCG partners for your reading pleasure! Enter your info and stay on top of things,

  • Fresh trends
  • Cases and examples
  • Research and insights
  • Two complimentary e-books