Java 使用p:tabView重复jsf ui

Java 使用p:tabView重复jsf ui,java,jsf,jsf-2,primefaces,Java,Jsf,Jsf 2,Primefaces,我感兴趣的是,是否有可能用jsf ui repeat标记创建p:tabView?我试图找到一个解决方案,如何创建从Java列表生成选项卡的循环。看见 事实证明,这要复杂得多。有什么可能的解决办法吗?试一试 <p:tabView id="tabView1"> <ui:repeat value="#{controllerBean.docList}" var="doc"> <p:tab title="Godfather Part I">

我感兴趣的是,是否有可能用jsf ui repeat标记创建
p:tabView
?我试图找到一个解决方案,如何创建从Java列表生成选项卡的循环。看见 事实证明,这要复杂得多。有什么可能的解决办法吗?

试一试

<p:tabView id="tabView1">
    <ui:repeat value="#{controllerBean.docList}" var="doc"> 
        <p:tab  title="Godfather Part I">  
            <h:panelGrid columns="2" cellpadding="10">  
                <p:graphicImage  value="/images/godfather/godfather1.jpg" />  
                    <h:outputText   
                        value="The story begins as Don Vito Corleone, the head of a New York Mafia family, oversees his daughter's wedding.  
                        His beloved son Michael has just come home from the war, but does not intend to become part of his father's business. T  
                        hrough Michael's life the nature of the family business becomes clear. The business of the family is just like the head of the family, kind and benevolent to those who give respect,  
                        but given to ruthless violence whenever anything stands against the good of the family." />  
            </h:panelGrid>  
        </p:tab>  
    </ui:repeat>
</p:tabView>


这是一个带有primafaces选项卡视图的简单jsf代码。

您可以执行以下操作

你的豆子

public class BeanName implements Serializable {

public BeanName(){
 personList = new ArrayList<Person>();
 personList.add(new Person("ajay", "mumbai"));
 personList.add(new Person("hari", "pune"));
}

private List<Person> personList;

    public List<Person> getPersonList() {
        return personList;
    }

    public void setPersonList(
            List<Person> personList) {
        this.personList= personList;
    }

}


    public class Person{

    private String name;

    private String address;

        public Person(String name, String address) {
            this.name=name;
            this.address=address;
        }

    public String getName(){
      return name;
    }

    public void setName(String name){
      this.name=name;
    }

    public String getAddress(){
      return address;
    }

    public void setAddress(String address){
      this.address=address;
    }
}
公共类BeanName实现可序列化{
公共BeanName(){
personList=新的ArrayList();
personList.add(新人(“阿杰”、“孟买”);
personList.add(新的人称(“hari”、“pune”);
}
私人名单个人名单;
公共列表getPersonList(){
回归人格;
}
公共无效设置个人列表(
列表(个人列表){
this.personList=personList;
}
}
公共阶层人士{
私有字符串名称;
私有字符串地址;
公众人物(字符串名称、字符串地址){
this.name=name;
这个地址=地址;
}
公共字符串getName(){
返回名称;
}
公共void集合名(字符串名){
this.name=name;
}
公共字符串getAddress(){
回信地址;
}
公共无效设置地址(字符串地址){
这个地址=地址;
}
}
Xhtml中的代码

<p:tabView rendered="#{not empty beanName.personList}" value="#{beanName.personList}" var="list">               
    <p:tab title="#{list.name}">here your data</p:tab>
</p:tabView>

这是你的数据

正如@p27所指出的,您可以使用p:tabView的value和var属性来动态地呈现集合中每个项的一个选项卡。 这是我所知道的唯一一种官方方法,因为c:forEach将在构建时应用,而不是像ui:repeat那样在呈现时应用(因此集合中不会有任何项目,也不会出现任何选项卡),并且ui:repeat在p:tabView组件中不起作用


问题是,如果要在同一个p:tabView中呈现一个或多个静态选项卡以及其他动态选项卡。这是不可能的,只要不添加虚拟项目(那些你会考虑静态的)到动态选项卡集合,每当它被创建,这样,集合总是会有它们里面。< /P>你到底尝试了什么?请在此发布一些代码如果
p:tabView
value
属性对集合有效,为什么要使用
ui:repeat
标记?我也尝试过,但它不起作用(更多?)。里面的一切都被忽略了,这是不应该发生的
p:tabView
只有“知道”如何处理
p:tab
子项。不是ui:重复