mediocre
mediocre

Reputation: 564

JSF template not applied

I'm running into a problem with JSF and templating. I'm following this tutorial but the only output I see is the one I'm defining in my index.xhtml with

<ui:composition template="/WEB-INF/templates/BasicTemplate.xhtml">
<ui:define name="content">
my custom content
</ui:define>

without adding the footer and header even though I'm not defining/overwriting the default one in my index file.

If I view the source in the browser it's showing up the same way as in my index.xhtml with ui:composition etc. So it looks like it's not "converting" it to HTML.

The relevant parts of my web.xml:

<servlet>
    <description>Controller Servlet for data input</description>
    <display-name>InputServlet</display-name>
    <servlet-name>InputServlet</servlet-name>
    <servlet-class>form.controller.InputServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>InputServlet</servlet-name>
    <url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<welcome-file-list>
    <welcome-file>index.xhtml</welcome-file>
</welcome-file-list>

My directory structure looks like this: https://i.sstatic.net/K0vsz.png

Thanks!

Upvotes: 0

Views: 943

Answers (1)

BalusC
BalusC

Reputation: 1108852

You're using the wrong servlet.

JSF comes with its own servlet, the FacesServlet.

Get rid of the InputServlet from web.xml altogether and map JSF's FacesServlet as follows:

<servlet>
    <servlet-name>facesServlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>facesServlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
</servlet-mapping>

That should do it.

See also:

Upvotes: 2

Related Questions