Search code examples
jsfprimefaceshead

One or more resources have the target of 'head'


I have few xhtml sites and the one which uses PrimeFaces print this error: One or more resources have the target of 'head'

this is my template file:

<html lang="pl"
  xmlns="http://www.w3.org/1999/xhtml"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:p="http://primefaces.org/ui"
  xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-type" />

    <link href="resources/css/bootstrap.css" rel="stylesheet"/>
    <link href="resources/css/font-awesome.css" rel="stylesheet"/>
    <link rel="stylesheet" type="text/css" href="resources/css/style.css"/>
    <link rel="stylesheet" type="text/css" href="resources/css/style-mobile.css"/>

    <script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
    <script src="resources/js/bootstrap.js"></script>
</h:head>
<h:body>
    <ui:insert name="header">
        <ui:include src="/global/top-menu.xhtml"/>
    </ui:insert>

    <ui:insert name="content">
        <ui:include src="/index.xhtml"/>
    </ui:insert>

    <ui:insert name="footer">
        <ui:include src="/global/footer.xhtml"/>
    </ui:insert>
</h:body>
</html>

and this is the content where the error is printed:

<!DOCTYPE html>
<html lang="pl"
      xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>

</h:head>

<h:body>
    <ui:composition template="/WEB-INF/template/mainLayout.xhtml">
        <ui:define name="content">

            <h:outputScript library="js" name="calendar-pl.js"/>
            <h:outputScript library="js" name="registration.js"/>

            <div class="container registration-container">
             //some PrimeFaces stuff which works properly by the way
            </div>

        </ui:define>
    </ui:composition>
</h:body>
</html>

Solution

  • I am using ui:composition this way:

    The template file:

    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets">
    <f:view contentType="text/html" locale="en">
    <h:head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <ui:insert name="headerExtend"></ui:insert>
    </h:head>
    <h:body>
             <ui:insert name="content"></ui:insert>
        </h:body>
     </f:view>
    </html>
    

    And here is the actual content inserted:

    <ui:composition
    template="./layout.xhtml"
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    
    xmlns:p="http://primefaces.org/ui">
    <ui:define name="content">
            <h:form>
            </h:form>
        </ui:define>
    </ui:composition>