Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to produce favicon <link> using JSF?

Tags:

jsf-2

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" />

like image 697
Robert Heine Avatar asked Jun 18 '13 13:06

Robert Heine


1 Answers

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:

  • When to use <ui:include>, tag files, composite components and/or custom components?
like image 97
BalusC Avatar answered Sep 24 '22 07:09

BalusC