0

i have an external CSS file in the resources folder under WebContent folder, and i included it at the page header as follows:

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

i tried a simple selector to test the if the file is working like body {background-color:#b0c4de;} but unfortunately the file isn't linked

for more clarity i included here a screenshot for the exact location of the resources folder

enter image description here

Eslam Hamdy
  • 7,126
  • 27
  • 105
  • 165

2 Answers2

4

First of all, this is not an external CSS file at all. It's internal to your web application. A real external CSS file would be served from a different domain and is not importable via <h:outputStylesheet>, but only via <link>.

Your concrete problem is caused because you unnecessarily repeated the CSS file folder into the library attribute. Just get rid of it.

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

The library attribute must represent the common module/theme/library name, such as "primefaces", but you don't have any here. Using a library name of "css" makes no utter sense as "css" just represents the file/content type.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • ok, i have applied different attributes to an as follows: #globalFilter { margin-left: 995px; margin-top:-30px; width:320px; height:20px; font-size: 11px; } but the element doesn't affected at all, do you know the reason? – Eslam Hamdy May 03 '13 at 15:17
  • This problem is completely unrelated to the question being asked. The CSS file is now successfully loaded, right? As to the new problem, just rightclick page in browser and do *View Source* to look at JSF-generated HTML output. Do you see any HTML element with `id="globalFilter"` which the CSS rule is expecting? See also http://stackoverflow.com/q/5878692/ Press `Ask Question` if you still stucks. – BalusC May 03 '13 at 15:30
0

Try h:outputStylesheet name="style.css" library="css" />

here is a ref: http://www.mkyong.com/jsf2/how-to-include-cascading-style-sheets-css-in-jsf/

worcin
  • 129
  • 5