我想从 Java 列表创建 Primefaces 选项卡。我测试了这段代码:
<p:tabView value="#{DatacenterProfileController.data}" var="listItem">
<p:tab title="#{listItem.name}">
<ui:insert>
<ui:include src="#{listItem.page}" />
</ui:insert>
</p:tab>
</p:tabView>
private List<PagesObj> dataList = new ArrayList<>();
public class PagesObj {
private String name;
private String page;
public PagesObj(String name, String page) {
this.name = name;
this.page = page;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPage() {
return page;
}
public void setPage(String page) {
this.page = page;
}
}
@PostConstruct
public void datagenerate(){
dataList.add(new PagesObj("General", "DCProfileTabGeneral.xhtml"));
dataList.add(new PagesObj("Zones", "DCProfileTabZones.xhtml"));
dataList.add(new PagesObj("Generators", "DCProfileTabGenerators.xhtml"));
dataList.add(new PagesObj("HVAC", "DCProfileTabHVACs.xhtml"));
}
public List<PagesObj> getdata() {
return dataList;
}
但由于某种原因,选项卡的正文未正确加载 - 我得到空的正文选项卡可能是因为找不到文件。你能帮我解决这个问题吗?