Tom H
Tom H

Reputation: 31

h:graphicImage does not display image in JSF

I have this in my class and I am trying to access it on my web page.

public String carImageURL = "/resources/images/sample_car.jpg";

This is the code I use in my web page that does not work.

<h:graphicImage value="#{carClass.carImageURL}"></h:graphicImage >

When I run the page there is no picture of the car in it.

Upvotes: 0

Views: 2478

Answers (1)

Javier Haro
Javier Haro

Reputation: 1255

Change the carImageURL attribute to private scope and write a getter method for it. Also write a slash at the beginning of the image path:

private String carImageURL = "/resources/images/sample_car.jpg";

public String getCarImageURL() {
    return carImageURL;
}

Upvotes: 0

Related Questions