Robert Heine
Robert Heine

Reputation: 1838

How to produce favicon <link> using JSF?

Is there a way using standard jsf-taglibs, which is rendered to <link> in the browser? My main goal is to produce a favicon link that should look like this:

<link href="/portal/faces/javax.faces.resource/image/favicon.ico?ln=some.lib" rel="shortcut icon" type="image/x-icon" />

Upvotes: 7

Views: 6634

Answers (1)

BalusC
BalusC

Reputation: 1109292

There is no standard JSF component/tag for this.

You can use #{resource} to convert a JSF resource identifier libraryName:resourceName to its domain-relative URL representation without the need to manually write down the context path, resource path, JSF mapping and query string.

<link href="#{resource['some.lib:image/favicon.ico']}" rel="shortcut icon" type="image/x-icon" />

If you want to get a step further, then you can always wrap this in a custom tag file in the same line as <h:outputStylesheet> and friends like so:

<my:favicon library="some.lib" name="image/favicon.ico" />

See also:

Upvotes: 11

Related Questions