7

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

Alexandre Lavoie
  • 8,711
  • 3
  • 31
  • 72
Robert Heine
  • 1,820
  • 4
  • 29
  • 61
  • I think the question is ok, but what are the reasons for not using html right away? – Aksel Willgert Jun 18 '13 at 13:38
  • Actually all tries setting this in a more "static" manor failed; if I simply copy the marked code into my template it's reduced to `` which leads to a 404 for favicon. – Robert Heine Jun 18 '13 at 13:42

1 Answers1

11

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:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555