如何在primeface中的tabview中启用选项卡?

时间:2014-07-29 00:59:21

标签: primefaces

我有一个包含两个标签的TabView。第一个标签有Boutton。如何在单击命令按钮时启用第二个选项卡

  <p:tabView id="tabView"  widgetVar="tabPanelWidget1">

        <p:tab id="firstTab" title="tab1">
            <h:form id="form1">
                      .........................
            <p:commandButton action="#{Bean.create}" value="Add" 
                         update=":content:tabView" />

            </h:form>
        </p:tab>

       <p:tab id="secondtab"  title="tab 2">
             <h:form id="form2">
                               .............
              </h:form>
       </p:tab>
 </p:tabView>

1 个答案:

答案 0 :(得分:0)

使用primefaces'选项卡javascript api,特别是select函数:

<p:commandButton action="#{Bean.create}" onclick="tabView.select(1);" value="Add" update=":content:tabView"/>

该函数的 1 参数是您要切换到的选项卡的索引。

相关问题