Dynamic Primefaces:tabView doesn’t update

jsfprimefaces

I'm using Primefaces 3.4 (also tried 3.3) and Mojarra 2.1.7. But I have a problem updating my dynamical tabs within a p:tabView.

I have 2 buttons which should add an additional tab. The first button is outside the p:tabView. When clicking this button, the backing bean is called, the p:tabView is updated, and the new tab is shown. But when I click the second button, which is inside a tab of that tabView, the backing bean is called, but the tabView is NOT updated.

This lack of updating occures only in dynamic tabs. When I modify the given example to have only one tab, and displaying a value which changes when clicking the buttons, the tabView is updated by both buttons, and the new Value is shown. So it is an problem only occuring in dynamic tabs.

Here is my code.

   <f:view contentType="text/html">
        <h:form>
            <p:commandButton value="press me" action="#{idTestBean.addTab}" update=":ApplicationTab"/>
        </h:form>

        <p:tabView id="ApplicationTab" cache="false" dynamic="false"  var="tab" value="#{idTestBean.tabList}">
            <p:tab title="tab" closable="false" >
                <p:panel>
                    <h:form>
                        <p:commandButton value="press me" action="#{idTestBean.addTab}" update=":ApplicationTab"/>
                    </h:form>

                    #{idTestBean.count}
                </p:panel>

            </p:tab>
        </p:tabView>
    </f:view>

The different tabs contains separate forms that needed to be submitted separate. therefore I had the approach of more than one form.

Best Answer

Well this must do the trick:

<f:view contentType="text/html">
    <h:form>
        <p:commandButton value="press me" action="#{idTestBean.addTab}" update="@form"/>


    <p:tabView id="ApplicationTab" cache="false" dynamic="false"  var="tab" value="#{idTestBean.tabList}">
        <p:tab title="tab" closable="false" >
            <p:panel>

                    <p:commandButton value="press me" action="#{idTestBean.addTab}" update="@form"/>


                #{idTestBean.count}
            </p:panel>

        </p:tab>
    </p:tabView>
    </h:form>
</f:view>
Related Topic