I am trying to update dynamically the content of the clicked tab inside a tabView in Primefaces. I am trying to simulate what I have inside the listener tag for my ajax, I know this doesn't work when clicking a tab because the EL inside the listener tag has already been evaluated to a string. The question, is there any way to do this?? Thanks for your help.
<p:tabView id="tv1" widgetVar="wv1" activeIndex="1">
<p:ajax event="tabChange"
listener="#{bean.onTabChange}"
update="#{bean.updatedTabID}"/>
<p:tab title="tab1">
<p:dataTable id="dtTab1">... </p:dataTable>
</p:tab>
<p:tab title="tab2">
<p:dataTable id="dtTab2">... </p:dataTable>
</p:tab>
</p:tabView>
Backing bean
String updatedTab
public String updatedTabID(){
return updatedTab;
}
public void onTabChange(TabChangeEvent event) {
Tab activeTab = event.getTab();
String activeTabTitle = activeTab.getTitle();
if(activeTabTitle.equals("tab1")){
updatedTab=":tv1:dtTable1";
// update dataTable1 collection
}else if(activeTabTitle.equals("tab2")){
updatedTab=":tv1:dtTable2";
// update dataTable2 collection
}
}