primefaces选项卡使用动态选项卡查看不同的选项卡内容 [英] primefaces tabView different tab content with dynamic tabs

查看:81
本文介绍了primefaces选项卡使用动态选项卡查看不同的选项卡内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对tabView有问题.第一个标签应该始终显示相同的内容(称为搜索模板,该搜索模板由#{not curSearch.isClosable()}标识.所​​有其他标签都是搜索实例(由#{curSearch.isClosable()}标识

I have a problem with tabView. The 1st tab should always display the same content (called search template which is identified with #{not curSearch.isClosable()}. All other tabs are search instances (identified with #{curSearch.isClosable()}

这是代码:

<p:tabView id="searchTabViewId" var="curSearch" value="#{searchBL.searchInstances}"
  activeIndex="#{searchBL.activeTabIndex}" styleClass="searchTabView">

  <!-- search template tab -->
  <ui:include src="/icarchive/sections/search/firstSearchTab.xhtml">
     <ui:param name="curSearch" value="#{curSearch}" />
  </ui:include>

  <!-- search instances tabs -->
  <ui:include src="/icarchive/sections/search/searchInstanceTab.xhtml">
     <ui:param name="curSearch" value="#{curSearch}" />
  </ui:include>

</p:tabView>

不幸的是,在第一个选项卡上有称为curSearch对象的方法,这些方法仅在第二个及以下选项卡上使用.如果我不使用ui:insert,它不会更改任何内容. 谁知道我的错在哪里?

Unfortunately there are methods on the 1st tabs curSearch object called which are used on 2nd and following tabs only. If I do not use the ui:insert it does not change anything. Anybody knows where is my fault?

问候 奥利弗(Oliver)

Regards Oliver

推荐答案

我遇到了同样的问题,我发现的唯一解决方案是将其他组件包装并包含在其中,并渲染显示的内容.对于初始加载,如果您具有基于内容的ID,则需要设置ID前缀,以使其不允许使用空ID字段:

I had the same problem, only solution i found is wrap include in other component and clamp with render which one is displayed. For initial load if you have ids depending on content you will need to set id prefix so that it does not allow empty id fields:

<p:tabView id="tabsView" dynamic="true" cache="true"
           value="#{TabViewController.tabView.openedTabs}" var="tabDefinition" activeIndex="#{TabViewController.tabView.activeIndex}">
    <p:ajax event="tabClose" listener="#{TabViewController.onCloseTab}" update="tabsView"/>
    <p:ajax event="tabChange" update="tabsView"/>
    <p:tab id="tab#{tabDefinition.id}" title="#{tabDefinition.title}" closable="true" action="">
        <f:facet name="title">
            <h:outputText value="#{tabDefinition.title}"/>
        </f:facet>
        <p:outputPanel style="display:block" rendered="#{'dataTable'.equals(tabDefinition.type)}">
            <ui:include src="dataTable.xhtml">
                <ui:param name="dataTableName" value="#{tabDefinition.contentName}"/>
            </ui:include>
        </p:outputPanel>
        <p:outputPanel style="display:block" rendered="#{'form'.equals(tabDefinition.type)}">
            <ui:include src="form.xhtml">
                <ui:param name="formId" value="#{tabDefinition.id}"/>
                <ui:param name="formName" value="#{tabDefinition.contentName}"/>
            </ui:include>
        </p:outputPanel>
    </p:tab>
</p:tabView>

这篇关于primefaces选项卡使用动态选项卡查看不同的选项卡内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆