0

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.

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
drhs
  • 25
  • 6
  • Use a title facet, put an outputText in there and update that. I'll try to find a duplicate Q/A for you – Kukeltje Sep 25 '17 at 12:46
  • ok thanks, I will try your suggestion. – drhs Sep 25 '17 at 12:47
  • Was the second hit doing https://www.google.nl/search?q=primefaces+update+title. Just searched without accordion to find more generic Q/A (always good to try that since solutions for different components are often identical – Kukeltje Sep 25 '17 at 13:11
  • ok might be my mistake that too focused on accordion component – drhs Sep 25 '17 at 13:13

0 Answers0