Como adicionar e remover dinamicamente uma guia no componente p: tabView
Estou tentando adicionar um PrimeFaces<p:tab>
dinamicamente. Ao adicionar a segunda guia, estou recebendo a seguinte exceção:
"java.lang.IllegalStateException: a identificação do componente tab0 já foi encontrada na visualização".
Como posso resolver isso
Aqui está o código de exibição:
<h:form prependId="false">
<p:tabView id="tabview" dynamic="true" cache="false"
binding="#{testBean.tabView}"
activeIndex="#{testBean.activeTab}" >
<h:commandButton value="Close" action="#{testBean.removeTab}"/>
</p:tabView>
<h:commandButton value="Add Tab" action="#{testBean.addTab}"/>
</h:form>
Aqui está o código do bean:
public String addTab() {
String tabId="tab"+id;
System.out.println("Gen Id: "+tabId);
tab = new Tab();
tab.setTitle("Title: "+tabId);
tab.setId(tabId);
System.out.println("Tab Id: "+tab.getId());
tabView.getChildren().add(id,this.tab);
id++;
return "tabtest.jsf";
}
public String removeTab() {
tabView.getChildren().remove(activeTab);
return "tabtest.jsf";
}