I am trying to make a very simple application. With a starting menu as a welcome page, however I am having problems with faces components not being displayed.
The relevant snippet of my web.xml
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>menu.xhtml</welcome-file>
</welcome-file-list>
<filter>
<filter-name>WelcomeFileFilter</filter-name>
<filter-class>giu.WelcomeFileFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>WelcomeFileFilter</filter-name>
<url-pattern>/menu.xhtml</url-pattern>
</filter-mapping>
My menu.xhtml file
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.prime.com.tr/ui"
xmlns:f="http://java.sun.com/jsf/core">
<h:form id="menuForm">
<h1><h:outputText id="menuTitle" value="Menu Principal"/></h1><br/><br/>
<h3><h:outputText id="patientsTitle" value="Pacientes"/></h3><br/>
<h:panelGrid id="patientsGrid" columns="2">
<h:outputText value="Consultar, Crear, Editar o Eliminar Paciente"/>
<p:commandButton id="goToPatientsButton" value="Ir"/>
</h:panelGrid><br/><br/>
<h3><h:outputText id="doctorsTitle" value="Medicos"/></h3><br/>
<h:panelGrid id="doctorsGrid" columns="2">
<h:outputText value="Consultar, Crear, Editar o Eliminar Medicos"/>
<p:commandButton id="goToDoctorsButton" value="Ir"/>
</h:panelGrid><br/><br/>
<h3><h:outputText id="medicalHistoryTitle" value="Historias Medicas"/></h3><br/>
<h:panelGrid id="medicalHistoryGrid" columns="2">
<h:outputText value="Consultar, Crear, Editar o Eliminar Historias Medicas"/>
<p:commandButton id="goToMedicalHistoriesButton" value="Ir"/>
</h:panelGrid>
<p:dataTable emptyMessage="Vacio" paginator="true"/>
</h:form>
I dont know what am I doing wrong, plain html components such as texts and buttons display correctly, however primefaces components such as datatables and messages are not being displayed.
If it serves for anything, my question is closely related to: How to set ‘JSF2 welcome-file’ with faces servlet mapping?
Thanks for any help
The
<welcome-file>cannot be a “virtual” URL. Define it to bemenu.xhtmland create aFilterwhich is mapped on/menu.xhtmland redirects to the proper URL.Or even better, you can also consider to just get rid of the
/faces/*prefix mapping altogether in favour of an extension mapping. I recommend to use*.xhtmlso that you never need to worry about the URLs and also not about the risk that the JSF source code get exposed when the enduser wishfully edits the URL to remove the JSF mapping.