I'm using JSF2 with Primefaces running on Tomcat 7. I have created a layout in baseLayout.xhtml as below: -
<h:body>
    <p:layout fullPage="true">
        <p:layoutUnit position="north" size="50" id="top">
            <h:form>
                <ui:include src="/template/header.xhtml" />
            </h:form>
        </p:layoutUnit>
        <p:layoutUnit position="south" size="20">
            <h:form>
                <ui:include src="/template/footer.xhtml" />
            </h:form>
        </p:layoutUnit>
        <p:layoutUnit position="west" size="400">
            <h:form>
                <ui:include src="/template/menu.xhtml" />
            </h:form>
        </p:layoutUnit>
        <p:layoutUnit position="center" size="400">
            <h:panelGroup id="centerContentPanel">
                <ui:include src="#{navigationBean.pageName}.xhtml" />
            </h:panelGroup>
        </p:layoutUnit>
    </p:layout>
</h:body>
I want to dynamically change the source of centerContentPanel without refreshing the whole page and just the centerContentPanel i.e for on click of link present in the menu.xhtml as below: -
<h:form id="form2">
       <f:ajax render=":centerContentPanel" execute="@this">
           <h:commandLink value="page1" action="#{navigationBean.doNav}" >
             <f:param name="test" value="/pages/page1" />
           </h:commandLink>
           <h:commandLink value="page2" action="#{navigationBean.doNav}" >
             <f:param name="test" value="/pages/page2" />
           </h:commandLink>
    </f:ajax>
</h:form>
. I tried doing that, but instead it refreshes the whole page without changing the URL, and when I refresh it again, the new page is included. I don't know what is happening. My NavigationBean as below:-
public class NavigationBean {
    private String pageName="/template/body";
    public NavigationBean() {
    }
    public String doNav() {
        System.out.println("Hello");
        String str = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("test");
        this.pageName = str;
        return pageName;
    }
    public String getPageName() {
        return pageName;
    }
    public void setPageName(String pageName) {
        this.pageName = pageName;
    }
}