Search code examples
jsfprimefacestabstabviewconditional-rendering

Dynamic TabView primefaces, tab rendered attribute doesn't work


i have a "problem" with a tab component for tabView from Primefaces. I did a tabView with dynamic tabs based on a array.

But some tabs can't be rendered, based on a boolean attribute of the object from that array .

I tried rendered="true" or "false" but nothing happens (on tab). I use rendered="#{_item.show}" i tried use disabled feature and works fine, but is not my need.

Someone have an idea to how to solve this issue?

check my code:

<p:tabView id="tabs" value="#{myBean.list}" var="_item"  orientation="left" style="height:800px!important;" >

        <p:tab title="#{_item}" rendered="#{_item.show}" >

Solution

  • Add disabled attribute to your <p:tab> and use this style for hiding tab:

    <style>
        #tabs li.ui-state-disabled {
            display: none;
        }
    </style>
    

    Value after # is your <p:tabView> clientId, so if it is in a naming container like <h:form id="myForm"> then just change your selector to #myForm\:tabs.

    rendered="false" works but it doesn't render content of the tab, not the tab itself.