PrimeFaces <p:tab>
을 동적으로 추가하려고합니다. 두 번째 탭을 추가하는 동안 나는 다음과 같은 예외가 점점 오전 :p : tabView 구성 요소에서 탭을 동적으로 추가 및 제거하는 방법
"java.lang.IllegalStateException을 : 구성 요소 ID의 tab0 이미 뷰에서 발견되었습니다."
어떻게 해결할 수 있습니까?
여기<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>
가 빈 코드 : 여기서
뷰 코드 동일한 ID가 새로운 탭 (UR 추가 할 것)에 대해 생성되고 있기 때문이다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";
}
이 id' 심하게 관리'것으로 보인다. 더 많은 코드를 게시 할 수 있습니까 (예 : 'id'선언)? 같은 페이지'tabtest.jsf'에 머 무르려면 BWT에서 메소드가'void'를 리턴 할 수 있습니다. –
@ janasoft : 어떻게 해결했는지 알려주세요 (지금 해결 된 경우)? –