5

Good morning, i have a problem in applying a style sheet on a primefaces commandButton , the button element is as follows:

        <p:commandButton value="Complains" styleClass="styleOrange"/>

and the style sheet:

    .styleOrange {    
    background-color: orange;
}

the css file is placed in the resources folder under css folder:

here's the include statement of the css file:

<h:head>

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

</h:head>
Eslam Hamdy
  • 6,706
  • 26
  • 101
  • 162

2 Answers2

12

There is no need for the /resources/ prefix. JSF already implicitly loads resources from there.

Just change the name into css/style.css, like this:

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

You should also read this What is the JSF resource library for and how should it be used?

Community
  • 1
  • 1
Daniel
  • 36,273
  • 9
  • 115
  • 187
-1

U must edit path of css file:

<h:outputStylesheet library="css" name="#{request.contextPath}/css/style.css"/>
Thangnv
  • 765
  • 3
  • 10
  • 22
  • Two things wrong here: 1) https://stackoverflow.com/questions/11988415/what-is-the-jsf-resource-library-for-and-how-should-it-be-used 2) the contextPath is included by the component. – Kukeltje Jun 29 '18 at 20:35