I want to ask a question, is there a way to update tab title especially in p:ajax event="tabClose"? Because when I tried to update the component using this ajax event, the title is changed but the tab is not closed and the component become stuck. Here is the code for accordian panel.
<p:accordionPanel id="searchEmployeeAccordionPanelId"
widgetVar="searchEmployeeAccordionPanelId"
dynamic="true"
cache="true"
activeIndex="#{Employee.accordionIndex}"
style="margin-left: #{Employee.searchEmployeeDataTablePanelRendered ? '20%':''}">
<p:ajax event="tabChange"
listener="#{Employee.tabChangeSearchEmployeeAction}"
update="@([id$=searchEmployeeAccordionPanelId])"
global="false"/>
<p:ajax event="tabClose"
listener="#{Employee.tabCloseSearchEmployeeAction}"
update="@([id$=searchEmployeeAccordionPanelId])" />
<p:tab id="tabTitleId" title="#{Employee.showSearchPanelGridLink}" >
<h:panelGrid id="searchEmployeePanelGridId"
rendered="#{Employee.searchEmployeePanelGridRendered}">
</h:panelGrid>
</p:tab>
</p:accordionPanel>
Here is the code for tabClose ajax event listener.
public String tabCloseSearchEmployeeAction(TabCloseEvent event) {
String activeIndex = ((AccordionPanel) event.getComponent()).getActiveIndex();
if (activeIndex.equalsIgnoreCase("0"))
{
event.getTab().setTitle(showSearchLabel);
showSearchPanelGridLink = event.getTab().getTitle();
}
return null;
}
Here is the code for tabChange ajax event listener.
public String tabChangeSearchEmployeeAction(TabChangeEvent event) {
String activeIndex = ((AccordionPanel) event.getComponent()).getActiveIndex();
if (activeIndex.equalsIgnoreCase("0"))
{
event.getTab().setTitle(hideSearchLabel);
showSearchPanelGridLink = event.getTab().getTitle();
}
return null;
}
Thanks for any help.