Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsf 在“面”选项卡视图上_Jsf_Primefaces - Fatal编程技术网

Jsf 在“面”选项卡视图上

Jsf 在“面”选项卡视图上,jsf,primefaces,Jsf,Primefaces,这是我们在tabview中添加选项卡的bean。很好用 public class Tabs { public Tabs() { fc = FacesContext.getCurrentInstance(); tabView = (TabView) fc.getApplication().createComponent( "org.primefaces.component.TabView

这是我们在tabview中添加选项卡的bean。很好用

    public class Tabs {
        public Tabs() {
            fc = FacesContext.getCurrentInstance();
            tabView = (TabView) fc.getApplication().createComponent(
                    "org.primefaces.component.TabView");
            Tab tab1 = new Tab();
            tab1.setTitle("Default tab");
                    Tab tab2 = new Tab();
            tab2.setTitle("Manage Favorites");
            tab2.setClosable(true);
            tabView.getChildren().add(tab1);
            tabView.getChildren().add(tab2);

            tabView.setActiveIndex(0);
        }

    public TabView getTabView() {
        return tabView;
    }

    public void setTabView(TabView tabView) {
        this.tabView = tabView;
    }

    public void addTabs() {
        Tab tab3 = new Tab();
        tab3.setTitle("Manage Favorites");
        tab3.setClosable(true);
        tabView.getChildren().add(tab3);
        System.out.println("Called");
    }

    FacesContext fc;
    TabView tabView;
}

这确实显示了选项卡,但它完全是空的。我想在这些选项卡中添加面板网格


问题是:如何在编程端添加panelgrid,以便选项卡视图显示一些信息?

如果只在
标记中定义要使用的选项卡,不是更容易吗

例如:


在jsf页面中定义选项卡会更容易,因为您要在页面中定义它,而不是通过方法调用它。只有当您需要更精细的实现来改变组件的行为时,通过方法调用它才有用

我从这里得到了这个例子:

祝你好运

<p:tabView id="mytabview" orientation="left" binding="#{Tabs.tabView}"
            style="position:relative" rendered="true" styleClass="tabs">
        </p:tabView>
<p:tab id="tab1" title="Godfather Part I">  
    <h:panelGrid columns="1" cellpadding="10">  
        <h:outputText id="tab1Text"  
            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>  

<p:tab id="tab2" title="Godfather Part II">  
    <h:panelGrid columns="1" cellpadding="10">   
        <h:outputText id="tab2Text" value="Francis Ford Coppola's legendary continuation and sequel to his landmark 1972 film, The_Godfather, parallels the young Vito Corleone's rise with his son Michael's spiritual fall, deepening The_Godfather's depiction of the dark side of the American dream.  
        In the early 1900s, the child Vito flees his Sicilian village for America after the local Mafia kills his family. Vito struggles to make a living, legally or illegally, for his wife and growing brood in Little Italy,  
        killing the local Black Hand Fanucci after he demands his customary cut of the tyro's business. With Fanucci gone, Vito's communal stature grows."/>  
    </h:panelGrid>  
</p:tab>