I'm currently dealing with a problem on a project I'm using Spring MVC with Facelets view technology.In my master template I'm currently having a menu and whenever I click a link from that menu my intent is to include another page in the current one. I followed this link How to ajax-refresh dynamic include content by navigation menu? (JSF SPA) ,but it didn't resolve my problem. As in the example, I included a page by default,which initially loads and everything seems ok but when I click on one of the links, I get a null pointer exception.
I would like to say that I read many posts where user @BalusC answered,but I still found no solution.Now I'm stuck in this part of the project and I feel it's almost impossible to continue.
The menu xhtml file is the following one:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core">
<h:panelGroup layout="block" id="menu-outer">
    <h:panelGroup layout="block" class="table">
        <h:form>
            <f:ajax render=":content">
                <ul id="mainNav">
                    <li>
                        <h:commandLink id="toRegister" value= "Register page" action="#{bean.setPage('registerPage')}" />   
                    </li>
                    <li>
                        <h:commandLink id="toDepartment" value= "Departments" action="#{bean.setPage('departmentPage')}"/> 
                    </li>
                    <li>
                        <h:commandLink id="toHealthcarePlan" value= "Healthcare plans" action="#{bean.setPage('healthPage')}" />    
                    </li>
                    <li>
                        <h:commandLink id="toContacts" value= "Contacts" action="#{bean.setPage('contactsPage')}" /> 
                    </li>
                </ul>
            </f:ajax>
        </h:form>
    </h:panelGroup>
</h:panelGroup>
<h:panelGroup id="content" layout="block">
    <ui:include src="/WEB-INF/view/#{bean.page}.xhtml" />
</h:panelGroup>
</ui:composition> 
The bean is the following one:
@ManagedBean
@ViewScoped
public class Bean implements Serializable{
    private String page;
    @PostConstruct
    public void init(){
        page="registerPage";
    }
    public String getPage() {
        return page;
    }
    public void setPage(String page) {
        this.page = page;
    }
}
The webapp directory is the following one(I wrote it by hand,hope I didn't miss anything).
webapp
 |-- META-INF
 |-- WEB-INF
 |    |-- view
 |    |    -- template
 |    |           |-- template.xhtml
 |    |           |-- menu.xhtml
 |    |    -- registerPage.xthml
 |    |    -- departmentPage.xthml
 |    |    -- healthPage.xthml
 |    |    -- contactsPage.xthml
 |    |-- app-servlet.xml
 |    |-- faces-config.xml  
 |    |-- web.xml   
 |               
 |-- home.xhtml
The exception is the following one:
Dec 29, 2015 11:09:18 PM com.sun.faces.context.PartialViewContextImpl processPartial
INFO: java.lang.NullPointerException
java.lang.NullPointerException
    at javax.faces.component.UIComponentBase.getRenderer(UIComponentBase.java:1402)
    at javax.faces.component.UIComponentBase.decode(UIComponentBase.java:785)
    at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1181)
    at com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback.visit(PartialViewContextImpl.java:507)
    at com.sun.faces.component.visit.PartialVisitContext.invokeVisitCallback(PartialVisitContext.java:183)
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1612)
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)
    at javax.faces.component.UIForm.visitTree(UIForm.java:371)
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623)
    at com.sun.faces.context.PartialViewContextImpl.processComponents(PartialViewContextImpl.java:377)
    at com.sun.faces.context.PartialViewContextImpl.processPartial(PartialViewContextImpl.java:252)
    at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:931)
    at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:696)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:521)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:138)
    at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:564)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:213)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1097)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:448)
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:175)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1031)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:136)
    at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:200)
    at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:109)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
    at org.eclipse.jetty.server.Server.handle(Server.java:446)
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:271)
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:246)
    at org.eclipse.jetty.io.AbstractConnection$ReadCallback.run(AbstractConnection.java:358)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:601)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:532)
    at java.lang.Thread.run(Thread.java:745)
 
    