Resource library getting ignored in h:graphicImage

casolorz picture casolorz · Dec 14, 2012 · Viewed 9.3k times · Source

I have the following tag:

<h:graphicImage value="Circle_Yellow.png" library="images" />

In my folder I have the following structure:

/resources/images/.....
/WEB-INF/....
/*.xhtml

When rendered that image shows up as:

<img src="Circle_Yellow.png">

However I do see other things using resources, for example

<script type="text/javascript" src="/www/javax.faces.resource/jquery/jquery.js.xhtmlln=primefaces"></script>

And if I go to /www/javax.faces.resource/Circle_Yellow.png?ln=images it works.

So what could I possibly be doing wrong that my library gets ignored on the h:graphicImage. Also it isn't just as an image, I have a css file that is failing too.

I'm using mojarra 2.1.16 and primefaces 3.4.1.

Answer

BalusC picture BalusC · Dec 14, 2012

The value attribute takes an URL, not the resource name. To specify the resource name, use the name attribute.

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

See also the <h:graphicImage> tag documentation for details.


Unrelated to the concrete problem, your usage of the library attribute is not entirely right. Please carefully read What is the JSF resource library for and how should it be used? You should be using it as

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