【发布时间】:2014-03-10 06:46:24
【问题描述】:
如何在使用 ajax 单击命令按钮时动态地在 primefaces 中的 tabview 中添加选项卡?
<p:tabView id="tabview" dynamic="true" cache="false"
binding="#{TestBean.tabView}"
activeIndex="0"
scrollable="true">
<p:tab title="tab1" closable="true">
<h:outputLabel value="1"></h:outputLabel>
</p:tab>
<p:tab title="tab2" closable="true">
<h:outputLabel value="2"></h:outputLabel>
</p:tab>
<p:tab title="tab3" closable="true">
<h:outputLabel value="3"></h:outputLabel>
</p:tab>
</p:tabView>
支持bean是
public class TestBean {
TabView tabView;
int id=0;
public TestBean() {
}
public String addTab() {
String tabId="tab"+id;
Tab tab = new Tab();
tab.setTitle("Title: "+tabId);
tab.setId(tabId);
tabView.getChildren().add(id,tab);
id++;
return "tabtest.jsf";
}
public TabView getTabView() {
return tabView;
}
public void setTabView(TabView tabView) {
this.tabView = tabView;
}
这是我的支持 bean。我是jsf 和Primefaces 的新手。请帮忙。
谢谢。
【问题讨论】:
标签: jsf primefaces