Layout into Tab of TabView

645 Views Asked by At

I have this tabView into a layoutUnit where I can add and remove tabs dinamically.

When I try to use a layout with layoutUnit into a tab I have graphical error. How must I do to use a layout into a tab? Can I also optimize tabView update when I add a new tab?

<p:layoutUnit position="center" resizable="true" styleClass="borderlessTopUnit" >
   <p:tabView  id="tabViewExt" activeIndex="#{tabViewManagedBean.activeIndex}" styleClass="borderlessUnit" >
       <p:ajax event="tabClose"  listener="#{tabViewManagedBean.onTabClose}" />
       <p:ajax event="tabChange" listener="#{tabViewManagedBean.onTabChange}" />

       <c:forEach  items="#{tabViewManagedBean.tabs}" var="tab_ext" varStatus="loop_ext" >
         <p:tab  title="#{tab_ext.title}" closable="#{tab_ext.closable}" >
           <f:subview id="tab_ext_#{loop_ext.index}" >
              <ui:include src="#{tab_ext.page}" />
           </f:subview>
         </p:tab>
       </c:forEach>       
   </p:tabView>
</p:layoutUnit>  
1

There are 1 best solutions below

0
On

A layout unit must have it’s own form instead, also avoid trying to update layout units because of same reason, update it’s content instead. You should nest tags within tags.

<p:layout fullPage="true">
    <p:layoutUnit position="center">
        <h:form>
            <p:tabView  id="tabViewExt" 
                        activeIndex="#{tabViewManagedBean.activeIndex}" 
                        styleClass="borderlessUnit" >
                <p:ajax event="tabClose"  listener="#{tabViewManagedBean.onTabClose}" />
                <p:ajax event="tabChange" listener="#{tabViewManagedBean.onTabChange}" />

                <c:forEach  items="#{tabViewManagedBean.tabs}" 
                            var="tab_ext" varStatus="loop_ext" >
                    <p:tab  title="#{tab_ext.title}" closable="#{tab_ext.closable}" >
                        <f:subview id="tab_ext_#{loop_ext.index}" >
                            <ui:include src="#{tab_ext.page}" />
                        </f:subview>
                    </p:tab>
                </c:forEach>       
            </p:tabView>
        </h:form>
    </p:layoutUnit>
</p:layout>