views:

40

answers:

3

Hi folks,

I'm designing the template for my new JSF2.0 App and I want to use the resources folder to store my css-file. Now I started to create a template-file, but I don't know how to link the css.

I tried:

<link rel="stylesheet" type="text/css" href="resources/css/style.css"/>

..but didn't work

Can somebody help me, pls. THX


<h:outputStylesheet library="css" name="style.css" target="head" />

That doesn't work either :-(


It still doesn't work! Maybe that resource-method is disabled?! It doesn't work with pictures either!

<h:graphicImage value="#{resource['img:logo.png']}"/>

The output in my browser looks like that:

<img src="RES_NOT_FOUND">

EDIT: Images working now. I stupidly set a wrong path -.- but the stylesheet is still not working

+1  A: 

You need to put public resources in the public webcontent (/webapp folder as on your screenshot). CSS files are downloaded/included by webbrowser, not by webserver and hence need to be directly public accessible.

BalusC
Thank you for that information. But I have another question: Maven (that I use) wants a folder named 'resources' under src/main. What is that folder for? I thought that's the folder for resources. cheers
Sven
With "resources", think of config/xml/properties files specifically for Java code.
BalusC
A: 

It works with plain old html:

<link href="./resources/css/style.css" rel="stylesheet" type="text/css" />

But i don't like it I would prefer JSF...

Sven
+1  A: 

Make sure you have h:head/h:body tags.

mikalaj