我想p:tabView
用 Java 列表生成。到目前为止,这是我测试过的代码:
JSF 页面:
<p:tabView value="#{bean.tabs}" var="listItem">
<p:tab title="#{listItem.tabid}">
` <ui:include src="#{listItem.tabfilename}" />
</p:tab>
</p:tabView>
托管豆:
List<TabObject> tabs = new ArrayList<>();
@PostConstruct
public void init() {
tabs.add(new TabObject("tab1.xhtml", "General"));
tabs.add(new TabObject("tab2.xhtml", "History"));
}
public class TabObject {
String tabfilename;
String tabid;
public TabObject(String tabfilename, String tabid) {
super();
this.tabfilename = tabfilename;
this.tabid = tabid;
}
public String getTabfilename() {
return tabfilename;
}
public void setTabfilename(String tabfilename) {
this.tabfilename = tabfilename;
}
public String getTabid() {
return tabid;
}
public void setTabid(String tabid) {
this.tabid = tabid;
}
}
public List<TabObject> getTabs() {
return tabs;
}
但由于某种原因,它不起作用。我可以看到生成的选项卡标题,但选项卡的正文是空的。你能帮我修复我的代码吗?
更新:
简单的选项卡运行良好:
<p:tabView dynamic="true" cache="false">
<p:tab id="tab1" title="General" >
<ui:include src="tab1.xhtml" />
</p:tab>
<p:tab id="tab2" title="Group Accounts" >
<ui:include src="tab2.xhtml" />
</p:tab>
<p:tab id="tab3" title="History" >
<ui:include src="tab3.xhtml" />
</p:tab>
</p:tabView>