title: Primefaces tab ajax partial update bug
body: <p>I believe there is a bug in the primefaces  when trying to partially updated it with ajax. I posted same query on primefaces forum but have no response from anyone.</p>
  
  <p>I have attached an example where I have a tabView with two tabs. When I click the 'Load New Tab Content' button it calls my backing bean to dynamically change the content of tab1. It should clear the existing contents of tab1 and load in new content which is just an inputText in this case. I then use the RequestContext.getCurrentInstance().update(updateIds) method to indicate that I want tab1 to refresh itself. The problem is the tab title does not change and the new inputText content is put in both tab1 and tab2 but I never specified to do anything to tab2 so don't understand why that also got a new inputText. You can take this code and try yourself to see if you get same results or correct me if I am doing something wrong.</p>
  
  <ul>
  <li>Primefaces 3.5</li>
  <li>Mojarra  JSF API (javax.faces/2.1) 2.1.15 (20121116-1711)  </li>
  <li>Mojarra JSF Implementation (javax.faces/2.1) 2.1.15 (20121116-1711)</li>
  <li>Tomcat 7.0.32 </li>
  <li>JDK 1.6.0_07</li>
  </ul>
  
  <p>**</p>
  
  <h2>dynamicTabLoading.xhtml</h2>
  
  <p>**</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"
     xmlns:h="http://java.sun.com/jsf/html"
     xmlns:f="http://java.sun.com/jsf/core"
     xmlns:ui="http://java.sun.com/jsf/facelets"
     xmlns:p="http://primefaces.org/ui"   &gt;
  
      &lt;h:head&gt;
        &lt;title&gt;Prime Prototype Dynamic Tabs&lt;/title&gt;
     &lt;/h:head&gt;
  
     &lt;h:body&gt;
  
        &lt;h:form id="myForm"&gt;
           &lt;p:panel&gt;
              &lt;h:outputText value="Dynamic Tab Loading..."&gt;&lt;/h:outputText&gt;
              &lt;p:commandButton id="loadTabContentBtn" value="Load New Tab Content"
                    actionListener="#{tabManager.loadNewTabContent}"  /&gt;
  
  
              &lt;p:tabView id="tabView1" binding="#{tabManager.tabViewComponent}" dynamic="true" &gt;
  
                 &lt;p:tab id="tab1" title="Tab 1" closable="true" &gt;   
                    &lt;h:outputText value="blank 1" /&gt;
                 &lt;/p:tab&gt;
  
                 &lt;p:tab id="tab2" title="Tab 2" closable="true" &gt;   
                    &lt;h:outputText value="blank 2" /&gt;
                 &lt;/p:tab&gt;      
  
              &lt;/p:tabView&gt;   
  
           &lt;/p:panel&gt;
        &lt;/h:form&gt;
  
        &lt;!-- TODO remove for production --&gt;
        &lt;ui:debug /&gt;
  
     &lt;/h:body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>**</p>
  
  <h2>TabManager.java</h2>
  
  <p>**</p>
  
  <pre><code>import java.util.ArrayList;
  import java.util.List;
  
  import javax.faces.bean.ManagedBean;
  import javax.faces.component.UIComponent;
  
  import org.primefaces.component.inputtext.InputText;
  import org.primefaces.component.tabview.Tab;
  import org.primefaces.component.tabview.TabView;
  import org.primefaces.context.RequestContext;
  
  @ManagedBean
  public class TabManager {
  
     private TabView tabViewComponent;
  
     public void loadNewTabContent() {
  
        /* get list of tabs from tabView*/
        List&lt;UIComponent&gt; tabs = getTabViewComponent().getChildren();
  
        /* get the first tab which had id="tab1" */
        Tab targetTab = (Tab)tabs.get(0);
        System.out.println("Target Tab Id is " + targetTab.getClientId());
  
        /* clear the tabs current content */
        targetTab.getChildren().clear();
  
        /* set new tab title and new content */
        targetTab.setTitle("Tab 1 Changed");            
        InputText inputTxt = new InputText();
        inputTxt.setValue("This is new content for Tab 1 ");
        targetTab.getChildren().add(inputTxt);
  
        List&lt;String&gt; updateIds = new ArrayList&lt;String&gt;();
        updateIds.add(targetTab.getClientId());
  
        RequestContext.getCurrentInstance().update(updateIds);
     }
  
     public TabView getTabViewComponent() {
        return tabViewComponent;
     }
  
     public void setTabViewComponent(TabView tabViewComponent) {
        this.tabViewComponent = tabViewComponent;
     }
  
  }
  </code></pre>
  
  <p>Thanks</p>