0

I've been fighting a problem where my primefaces app could not locate my stylesheet using the tag

I finally "solved" it by using:

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

I'm still wondering why the tag didn't work, especially since I spent a while on it thinking maybe the file was in a bad location.

In the code below, when I inspect the source I don't see the link tag nor does it load the CSS file. I've left in the combinations I tried as well as the link tag which does work.

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">

<h:head>

</h:head>

<h:body>
    <h:outputStylesheet library="css" value="my.css"/>
    <h:outputStylesheet value="css/my.css"/>
    <link rel="stylesheet" type="text/css" href="css/my.css" />

    <h1>Hello World PrimeFaces</h1>
    <h:button value="xys" />
    <p:editor value="uuu" />
    <p:spinner />

</h:body>
</html>
irieill
  • 1,203
  • 10
  • 32
user6627139
  • 406
  • 6
  • 16
  • This structure should work. Have you tried putting style type ? May be this should in

    tag.

    – P P Jul 22 '16 at 23:08
  • 2
    Possible duplicate of [JSF/Facelets : CSS file is not being recognized using tag](http://stackoverflow.com/questions/12281839/jsf-facelets-css-file-is-not-being-recognized-using-houtputstylesheet-tag) – irieill Jul 22 '16 at 23:29
  • Agree with @irieill, so make sure the `*.css | *.js | *.images` are included in a **resources** folder inside the `WebContent` which is how jsf uses the resources! I recommend you read this: http://stackoverflow.com/a/11988418/2940051 – Esteban Rincon Jul 24 '16 at 00:43
  • I appreciate all the answers. I tried all those and none seem to work. I've had it working with other projects so not sure what's the difference. It's possible it is a problem with how intellij is copying files to the target directory although I do see them there in a resources folder. I started with a default web project and converted to maven which has different folder structure. It is working with my link tag so need to move on. – user6627139 Jul 30 '16 at 19:17

0 Answers0