Question

In my JSF webApp I have put all of my resources (js, css, img) into a versioned library as pointed out by BalusC in this answer.

Now my favicon also resided here:

resources --> default --> 1_1 --> img --> favicon.ico

According to this answer the way to add the favicon would be:

<link rel="shortcut icon" 
    type="image/x-icon" href="#{request.contextPath}/resources/default/1_1/img/favicon.ico"/>

But this way the resource handling that automatically picks files from the highest version folder (e.g. 1_1) is ignored and I would have to change this manually every time.

So is there another way to include the favicon or should the favicon be placed elsewhere (out of the versioned library)?

Was it helpful?

Solution

Use implicit EL #{resource} handler to let JSF convert a resource identifier to proper URL.

<link ... href="#{resource['default:img/favicon.ico']}" />

Note that this is also the way you're supposed to use to reference background images in CSS files.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top