Björn Landmesser

Software-Entwicklung, Fotografie

Refer to resources in CSS with JSF 2

| 2 Kommentare

Amazing how difficult it is to find out how to refer to images in a CSS file in JSF 2 using libraries. But finally I found it out with the help of a colleague.

Imagine you have an image background.png in a resource library called images. When you want to use this image as background in CSS you just write

.myclass {
    background-image: url(#{resource['images:background.png']});
}

Not so difficult, isn’t it?

2 Kommentare

  1. this seems not to work in netbeans 7.3.1 :
    nb shows thee error-message :

    „Unexpected token LBRACKET found

    Unexpected character(s) „url(#{“ found“

    • Well, that sonds like NB does not expect EL expressions in CSS. But it should work nontheless. NB is just the IDE that tries to interpret the file. JSF should be able to interpret it correctly.

Schreibe einen Kommentar

Pflichtfelder sind mit * markiert.