I'm trying to apply this answer to rendering a part of my primefaces page but the problem is that I need to click twice before getting the part changed is there a solution ?
this is my code
index.xhtml
 <html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:p="http://primefaces.org/ui"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:ui="http://java.sun.com/jsf/facelets">
 <h:head>
 </h:head>
  <h:body>
    <h:panelGroup id="header" layout="block">
        <h1>Header</h1>
    </h:panelGroup>
    <h:panelGroup id="menu" layout="block">
        <h:form>
            <f:ajax render=":content">
                <p:commandButton value="next" action="#{navBean.next}" />            
                <p:commandButton value="back" action="#{navBean.back}" />
            </f:ajax>
        </h:form>
    </h:panelGroup>
    <h:panelGroup id="content" layout="block">
        <h:panelGroup rendered="#{navBean.activePage == 'firstAjax'}">
            <ui:include src="firstAjax.xhtml" />
        </h:panelGroup>
        <h:panelGroup rendered="#{navBean.activePage == 'lastAjax'}">
            <ui:include src="lastAjax.xhtml" />
        </h:panelGroup>
    </h:panelGroup>
   </h:body>
  </html>
and this is my managedBean
 package com.project.beans;
 import javax.faces.bean.ManagedBean;
 import javax.faces.bean.SessionScoped;
 @ManagedBean(name = "navBean")
 @SessionScoped
 public class NavBean {
private String activePage = "firstAjax";
public String getActivePage() {
    return activePage;
}
public void setActivePage(String activePage) {
    this.activePage = activePage;
}
public void next() {
    System.out.println("next in " + activePage);
    this.setActivePage("lastAjax");
    System.out.println("next out " + activePage);
}
public void back() {
    System.out.println("back in " + activePage);
    this.setActivePage("firstAjax");
    System.out.println("back out " + activePage);
}
}
the firstAjax.xhtml and the lastAjax.xhtml is nearly the same
<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">
<h:form>
    <h2>content first</h2>
</h:form>
</ui:composition>
 
     
    