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

2 Answers 2

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:

Sign up to request clarification or add additional context in comments.

2 Comments

ok, i have applied different attributes to an <p:inputText id="globalFilter" value="Search"/> 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?
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 stackoverflow.com/q/5878692 Press Ask Question if you still stucks.
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/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.