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?
14. August 2013 um 7:57
this seems not to work in netbeans 7.3.1 :
nb shows thee error-message :
„Unexpected token LBRACKET found
Unexpected character(s) „url(#{“ found“
15. August 2013 um 20:32
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.