Peter Penzov
Peter Penzov

Reputation: 1658

How to include image into css file using JSF tag

I have this css file which sets background image into JSF page:

body { padding: 35px; background: #4c4c4c url(images/grad1.png) 0 0 repeat-x; color: #fff; font: 11px/normal Arial, Helvetica; }

I want to use this tag in order to include the image as JSF resource:

<h:graphicImage library="images" name="grad1.png" />

How I can include the image into the css file as JSF resource?

Upvotes: 1

Views: 891

Answers (1)

BalusC
BalusC

Reputation: 1108632

Provided that your CSS file is loaded via <h:outputStylesheet>, use #{resource} mapping.

body {
    padding: 35px; 
    background: #4c4c4c url(#{resource['images/grad1.png']}) 0 0 repeat-x; color: #fff; 
    font: 11px/normal Arial, Helvetica;
}

Upvotes: 3

Related Questions