How to Solve Warning Message One or more resources have the target of ‘head’, but no ‘head’ component has been defined within the view when executing JSF web page

Posted on

Introduction

This is an article where there is a warning message appear upon executing a JSF web page. The following image is depicting the warning message appear where the warning itself is ‘One or more resources have the target of ‘head’, but no ‘head’ component has been defined within the view.’. In order to describe it in detail, the following is the image for that :

How to Solve Warning Message One or more resources have the target of 'head', but no 'head' component has been defined within the view when executing JSF web page
How to Solve Warning Message One or more resources have the target of ‘head’, but no ‘head’ component has been defined within the view when executing JSF web page

The above warning appearance also exist in another article for further discussion and information. That article exist in the article in this link. Before going on further, the following is the actual XHTML file representing the JSF web page in the execution where the warning message appear :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui">
      <head>
            <title>TODO supply a title</title>
            <meta name="viewport" content="width-device-width, initial-scale=1.0"> 
      </head>
      <body>
            <div>TODO content</div>
            <div class="card">
                 <h:form>
                 <h5>Form User with only Basic InputText</h5>
                 <h5>Hello, <p:outputLabel for="username" value="#{basicInputTextView.username}"></p:outputLabel></h5>
                 <p:inputText id="username" value="#{basicInputTextView.username}"/>
                 <p:commandButton actionListener="#{basicInputTextView.submit}" value="Submit" />
                 </h:form> 
            </div>
      </body>
</html>

How to Solve Warning Message

The solution to solve the warning message is very easy. Just add the ‘head’ component because of the message given informing that it does not has been defined within the view when executing JSF web page. So, the following is the step for solving it :

  1. Just check the script available as exist in the above part. The ‘head’ tag element exist. But it does not considered as the head tag element which is recognized.

  2. According to another article exist before, there is a solution to solve and make the warning message disappear. It is by changing to the suitable head tag element. It is by using the head tag element from another namespace which in this context, it is the ‘h’ namespace. So, just edit the XHTML file as follow :

    <?xml version="1.0" encoding="UTF-8"?> 
    <!DOCTYPE html> 
    <html xmlns="http://www.w3.org/1999/html" 
          xmlns:h="http://java.sun.com/jsf/html" 
          xmlns:p="http://primefaces.org/ui"> 
          <h:head> 
               <title>TODO supply a title</title> 
               <meta name="viewport" content="width-device-width, initial-scale=1.0"> 
          </h:head> 
          <body> 
               <div>TODO content</div> 
               <div class="card"> 
                    <h:form> 
                        <h5>Form User with only Basic InputText</h5> 
                        <h5>Hello, <p:outputLabel for="username" value="#{basicInputTextView.username}"></p:outputLabel>
                        </h5> 
                        <p:inputText id="username" value="#{basicInputTextView.username}"/> 
                        <p:commandButton actionListener="#{basicInputTextView.submit}" value="Submit" /> 
                    </h:form> 
               </div> 
           </body> 
    </html>
  3. After editing it, just refresh the page once more without having to compile or to redeploy the application. If no other error message appear, the warning message will disappear.

Leave a Reply