Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.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 Primefaces按需加载选项卡式面板组件不工作_Jsf_Jsf 2_Primefaces - Fatal编程技术网

Jsf Primefaces按需加载选项卡式面板组件不工作

Jsf Primefaces按需加载选项卡式面板组件不工作,jsf,jsf-2,primefaces,Jsf,Jsf 2,Primefaces,我试图做一个Primefaces按需加载选项卡式面板组件,其中有一个InputExtArea组件。我遵循这个教程。 我的.xhtml表单如下所示: <h:form> <h:outputText value="Write a comment" /> <p:tabView dynamic="true" cache="true"> <p:tab title="Possitive"&

我试图做一个Primefaces按需加载选项卡式面板组件,其中有一个InputExtArea组件。我遵循这个教程。 我的.xhtml表单如下所示:

<h:form>
        <h:outputText
            value="Write a comment" />
        <p:tabView dynamic="true" cache="true">
            <p:tab title="Possitive">
                <h:panelGrid columns="2" cellpadding="10">
                    <p:inputTextarea rows="5" cols="130" />
                </h:panelGrid>
            </p:tab>
            <p:tab title="Negative">
                <h:panelGrid columns="2" cellpadding="10">
                    <p:inputTextarea rows="5" cols="130" />
                </h:panelGrid>
            </p:tab>
        </p:tabView>
        <p:commandButton value="Publish"></p:commandButton>
    </h:form>

但是这些InputExtBox总是被加载的,不过我没有点击它们。它们只能按需加载吗?如何做到这一点


提前感谢您的帮助

Primefaces为所有选项卡构建JSF树。两个InputExtArea都是在服务器端创建的。可以通过ui:include解决。将p:tab的内容放入额外文件,并使用ui:include获取内容:

<p:tabView>
    <p:tab title="Possitive">
        <ui:include src="#{tabViewBean.getTabSource('tabPositive')}"/>
    </p:tab>
    <p:tab title="Negative">
        <ui:include src="#{tabViewBean.getTabSource('tabNegative')}"/>
    </p:tab>
</p:tabView>
您应该在某个地方有EmptyTab.xhtml。在p:tabView中设置listener以侦听选项卡更改事件:

<p:tabView listener="#{tabViewBean.tabChangeListener}">

对不起,我不明白如何应用这个。
<p:tabView listener="#{tabViewBean.tabChangeListener}">
public void tabChangeListener(UIComponentBase tabView)
{
    activeTabName = getTabNameByIndex(tabView.getActiveIndex());
}

public String getTabNameByIndex(int index)
{
  if (i==0) return "tabPositive";
  if (i==1) return "tabNegative";
}