【问题标题】:AccordionPanel doesn't render the last tabAccordionPanel 不呈现最后一个选项卡
【发布时间】:2012-12-29 07:31:50
【问题描述】:

我正在使用 JSF 和 Primefaces 进行开发,并在我当前的一个项目中使用accordionPanel 组件。这是关于我如何使用它的 sn-p 代码:

<p:accordionPanel id="historic" dynamic="true" 
                  styleClass="noborder" 
                  activeIndex="-1">

    <p:tab id="tab1" title="Historic 1" >
            <ui:include src="historic1.xhtml"/>
    </p:tab>

    <p:tab id="tab2" title="Historic 2">
            <ui:include src="historic2.xhtml"/>
    </p:tab>

    <p:tab id="tab3" title="Historic 3">
            <ui:include src="historic3.xhtml"/>
    </p:tab>

    <p:tab id="tab4" title="Historic 4">
            <ui:include src="historic4.xhtml" />
    </p:tab>

</p:accordionPanel>

所有选项卡都包含基本相同的代码,一个包含一些数据指向不同数据集的表单。正如你们所看到的,它非常简单并且可以正常工作,除了最后一个选项卡。它从未显示过,无论它包含什么。我的意思是,如果,而不是上面的代码,我把它放在另一个:

<p:accordionPanel id="historic" dynamic="true" 
                  styleClass="noborder" 
                  activeIndex="-1">
    <p:tab id="tab1" title="Historic 1" >
            <ui:include src="historic1.xhtml"/>
    </p:tab>

    <p:tab id="tab2" title="Historic 2">
            <ui:include src="historic2.xhtml"/>
    </p:tab>

    <p:tab id="tab3" title="Historic 3">
            <ui:include src="historic3.xhtml"/>
    </p:tab>

    <p:tab id="tab4" title="Historic 4">
            <ui:include src="historic4.xhtml" />
    </p:tab>

    <p:tab id="tab5" title="Historic 5">
           Some plain test text.
    </p:tab>

</p:accordionPanel>

然后现在显示 tab4,但不显示 tab5。我目前正在使用最后一个代码,但由于标签为空,它有点难看。 你们有没有人遇到过相同或类似的问题,可以帮助我吗?我会很感激的。

【问题讨论】:

    标签: jsf primefaces


    【解决方案1】:

    来自 primefaces vdl:http://www.primefaces.org/docs/vdl/3.4/primefaces-p/accordionPanel.html

    活动索引

    活动选项卡的索引或逗号分隔的索引字符串,当 多模式开启。默认为零。

    您将其设置为 -1 可能是有原因的,如果您将其设置为 0 或正数,您提供的示例适用于 primefaces 3.4.2

    【讨论】:

    • 它有效。十分感谢。我只是认为accordionPanel 索引是一个从零开始的系统。我的意思是,第一个选项卡为零,依此类推。那是一个错误。再次感谢。
    • 我很抱歉这么说,但最终它没有用。我不知道为什么在我尝试的时候它会这样做,可能是因为缓存,但我刚刚再次运行该应用程序并且它失败了。无论如何,我已经找到了解决方案,我将其写在下面作为我自己问题的答案。
    【解决方案2】:

    accordionPanel 索引是从零开始的索引。也就是说,第一个选项卡为 0,第二个选项卡为 1,依此类推。因此 a 尝试使用“-1”作为索引,因为我不希望默认打开任何选项卡。 但是这个值 (-1) 会在手风琴面板中产生故障:最后一个选项卡没有正确打开。因此,如果 -1 不起作用并且 0 是第一个选项卡的值,那么“超过”最后一个选项卡的值呢?我的意思是,如果我们有 4 个选项卡(索引从 0 到 3),让我们尝试使用 4... 并且它可以工作。很简单。我希望这对发现自己遇到同样问题的人有所帮助。 无论如何,谢谢@Aksel Willgert,你给了我线索。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多