I need some help, I'm using primefaces 3.1 and doing some pages, and I want to load this pages into a tabview, and each page depends of each other.
Like This.
<p:tabView id="tabView1">
<p:tab id="tabInfo" title="title1">
<ui:include src="page1.xhtml"/>
</p:tab>
<p:tab id="tab2" title="title2" >
<ui:include src="page2.xhtml"/>
</p:tab>
<p:tab id="tab3" title="title3">
<ui:include src="page3.xhtml"/>
</p:tab>
</p:tabView>
page 2 depends form page 1 for making some validations and present or not the page 2 this information, page3 need the same.
How can I do for when I select tab2 call again the ManagedBean of page 2 and reload page 2 and make that validations and present the data?.
This validations and all the serach of the information is on the init Method.
Please help me with this.
And I apologize for my poor english.
Thanks,
You need to add something like this to your tabView:
<p:tabView id="tabView1">
<p:ajax event="tabChange" listener="#{yourBean.onTabChange}" update=":tab2"/>
...
Update to answer your comment:
The method onTabChange could look like this:
public void onTabChange(TabChangeEvent event) {
// ...
}
event provides the selected tab:
event.getTab()
you could now rerender all of your tabs with:
... update=":tabInfo, :tab2, :tab3"
or you store the selected tab in your bean and do something like this:
... update="#{yourBean.selectedTab}"
where selectedTab would look like this:
public String getSelectedTab(){
// selectedTab is a variable that should be set onTabChange()
return selectedTab;
}