I have entered the following code:
<h:outputStylesheet library="css" name="style.css" target="body" />
The problem is that it is giving me an error on target="body" saying:
The attribute target is not defined in the component outputStylesheet
In the html part if the html I have the following:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:pe="http://primefaces.org/ui/extensions">
How can I solve this issue?
Thanks
Look in the tag documentation of <h:outputStylesheet>
. It indeed doesn't list target
attribute. Perhaps you're confusing with the one from <h:outputScript>
.
The <h:outputStylesheet>
is by default always relocated to HTML <head>
, for the very simple reason because it's illegal to have a <style>
or <link>
element inside the HTML <body>
. The <h:outputScript>
however is by default located at exactly the same location as where it's been declared. The <script>
element as generated by it may be placed anywhere in the HTML <head>
or <body>
. You can let JSF auto-relocate this by setting the target
attribute to head
(will then appear in <head>
) or body
(will then appear in end of <body>
).
Just remove it. If target="body"
would theoretically have worked, it would only end up in illegal HTML output anyway.
<h:outputStylesheet library="css" name="style.css" />
Unrelated to the concrete problem, a resource library name of "css" is semantically wrong. Put it in the resource name.
<h:outputStylesheet name="css/style.css" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With