【问题标题】:How do I enable tabs in tabview in primefaces?如何在 primefaces 的 tabview 中启用选项卡?
【发布时间】:2014-07-29 00:59:21
【问题描述】:

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

  <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>

【问题讨论】:

  • 一定要用ajax吗?您将使用 primefaces 选项卡 javascript API 获得更好的结果
  • 请告诉我你的方法!

标签: primefaces


【解决方案1】:

使用 primefaces 的标签 javascript api,特别是 select 函数:

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

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

【讨论】:

    猜你喜欢
    • 2011-09-24
    • 2014-08-21
    • 2017-03-14
    • 2013-04-17
    • 2018-12-30
    • 2019-11-17
    • 1970-01-01
    • 2014-12-30
    • 2013-12-03
    相关资源
    最近更新 更多