繁体   English   中英

jsf ui重复p:tabView

[英]jsf ui repeat with p:tabView

我有兴趣用jsf ui repeat标签创建p:tabView吗? 我试图找到一种解决方案,该方法如何创建从Java列表生成选项卡的循环。 这里 事实证明,这要复杂得多。 有没有可能的解决方案?

你可以喜欢

你的豆

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;
    }
}

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的 valuevar属性动态地为您放置在value中的集合中的每个项目渲染一个选项卡。 据我所知,这是执行此操作的唯一官方方法,因为c:forEach将在构建时而不是在ui:repeat之类的渲染时应用(因此,集合中将没有任何项目,并且不会显示任何选项卡),而ui:repeat将无法在p:tabView组件中使用。

问题是,是否要在同一p:tabView中与其他动态标签一起呈现一个或多个静态标签。 每当创建动态选项卡集合时,不向虚拟选项卡集合中添加虚拟项(您会认为是静态的),就无法做到这一点,因此,该集合始终将它们包含在其中。

试一试。

<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 tabview的简单jsf代码。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM