I've done something similar with different results.
<h:form id="tabForm">
<p:tabView id="tabView" dynamic="true" cache="false">
<p:tab id="tba1" title="Tab 1">
#{viewMBean1.hello}
</p:tab>
<p:tab id="tab2" title="Tab 2">
#{viewMBean2.hello}
</p:tab>
</p:tabView>
</h:form>
On my managed beans I've written the following methods:
@PostConstruct
public void setup() {
System.out.println("ViewMBean1");
}
@PostConstruct
public void setup() {
System.out.println("ViewMBean2");
}
This is what the console shows when loading the page:
ViewMBean1
I noticed that, once loaded, the view beans are not removed from view scope when changing tabs. This may be something you don't want to happened. In that case you could remove the beans from view scope through a change listener.
<p:ajax event="tabChange" listener="#{tabViewManager.onTabChange}" process="@this" global="false" />
On TabViewManager:
public void onTabChange(TabChangeEvent event) {
Map<String, Object> viewMap = FacesContext.getCurrentInstance().getViewRoot().getViewMap();
viewMap.remove("viewMBean1");
viewMap.remove("viewMBean2");
}