Introduction
This article is actually part or the continuation of the previous article. That previous article exist in this link with the title of ‘How to Solve Error Message XML Parsing Error: prefix not bound to a namespace when running Java Web Application using Primefaces Framework’. The problem in this article is the JSF file cannot parse a certain part of HTML element. It occurs after successfully defining a ‘ui:composition’ tag to use a certain template. So, this article’s purpose is to define a header correctly for the JSF file. But it does not appear after defining it. The reason is because the JSF file may have fail to parse it. Before going in further, there are certain setting and also configuration for the Java web application.
Actually, it is referring from several previous articles. Those articles are the one for creating a maven-based Java web application in this link. It is an article with the title of ‘How to Create maven-based Web Application in NetBeans IDE’ for showing how to create a maven-based Java web application. Another one exist in this link for giving information. It is about how to add JSF library to the Java web application. That article has the title of ‘How to Add JSF Library to a maven-based Web Application in NetBeans IDE’. The third article is for adding Primefaces to the Java web application. That third article exist in this link with the title of ‘How to Add Primefaces Library to a maven-based Java Web Application in NetBeans IDE’. Below is part of the script which is the base for going further to add header part in the JSF file :
<?xml version="1.0" encoding="UTF-8"?> <ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"> </ui:composition>
Actually, there is an attempt by editing the script above for defining the header part of the JSF file as follows :
<?xml version="1.0" encoding="UTF-8"?> <ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"> <ui:define name="header"> <title>Admin Header</title> </ui:define> </ui:composition>
The following is the appearance of the above script :
After adding the HTML namespace in the ui:composition tag as ‘xmlns=”http://www.w3.org/1999/xhtml”‘, the JSF file will perfectly render the header part. So, the title available as part of the header will appear as the title of the JSF page. Overall, the revision using the namespace exist below :
<?xml version="1.0" encoding="UTF-8"?> <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"> <ui:define name="header"> <title>Admin Header</title> </ui:define> </ui:composition>
After editing and refreshing the page, the header part will appear as in the following image :