Another article is exist which is focusing on how to solve an error occur. The error appear in the form of the disability to parse a JSF file. Specifically, that JSF file is part of a Java web application. The Java web application is using an AdminFaces template with the name of ‘admin.xhtml’ in its ‘index.xhtml’ file. Before going on further, check the Java web application’s setting and configuration from several previous articles. The first one is showing how to create a maven-based Java web application. It is an article with the title of ‘How to Create maven-based Web Application in NetBeans IDE’ and it exist in this link. The second one is informing how to add JSF library for the Java web application. That article is available in this link with the title of ‘How to Add JSF Library to a maven-based Web Application in NetBeans IDE’. Finally, the third one is an article exist in this link with the title of ‘How to Add Primefaces Library to a maven-based Java Web Application in NetBeans IDE’.
Initial Base Content Script Page of ‘index.xhtml’ file
Actually, there is one another important thing after the setting and the configuration of the Java web application. It is the base content of the ‘index.xhtml’ as 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:composition>
The above snippet part is available from the previous article. That article is an article with the title of ‘How to Solve Error HTML Parsing is not working in a JSF File of Java Web Application running using Primefaces Framework’. Furthermore, it exist in this link. Apparently, the main target is just to be able to display the admin page template. In order to do that, just add an attribute to the ‘ui:composition’ tag. That attribute is the template attribute which in the form of ‘template=’/admin.xhtml’. By adding the attribute, the following is the additional part to the above snippet code :
<?xml version="1.0" encoding="UTF-8"?> <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" template="/admin.xhtml"> </ui:composition>
So, the output of the above script exist as follows :
Unfortunately, the process for rendering the ‘admin.xhtml’ file page ends in a failure. Instead of the ‘admin.xhtml’ page, it display the snippet code content in the page.
How to Solve Error Admin Page from AdminFaces is not rendering
So, there is actually a specific treatment for solving the problem. In other words, in order to get the admin page from AdminFaces template is loading properly. Actually, it is by adding a specific lines of configuration in a file with the name of ‘web.xml’. That file exist in the project of the Java web application. Precisely, it is available in the ‘Web Pages/WEB-INF’ folder. That specific lines of configuration is actually replacing the old one. The following is the old one :
<servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>/faces/*</url-pattern> </servlet-mapping>
The reason is because the structure of the AdminFaces template where it points out the JSF file which is represented with XHTML file is not in the URL path of ‘/faces/’. In that case, change the above old one with the new one as the revision below :
<servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>*.xhtml</url-pattern> </servlet-mapping>
Finally, in order to see the changes, just build, compile and run the Java web application. In this case, the process is possible from NetBeans IDE. If there are no more error appear, the following page of the ‘admin.xhtml’ from the AdminFaces template will appear :