【问题标题】:Reload <p:tab> info with <p:commandButton> action使用 <p:commandButton> 操作重新加载 <p:tab> 信息
【发布时间】:2023-03-09 18:37:01
【问题描述】:

我有一个带有 2 个标签的 &lt;p:tabView&gt;。第一个包含学生详细信息,第二个包含所有学生的表格。

<p:tab title="List">
    <p:dataTable id="studentsTable" value="#{studentMB.allStudents}" var="student">
        <p:column>
            <f:facet name="header"><h:outputText value="ID"/></f:facet>
            <h:outputText value="#{student.id}"/>
        </p:column>
        <p:column>
            <f:facet name="header"><h:outputText value="Name"/></f:facet>
            <h:outputText value="#{student.name}"/>
        </p:colum>
        <p:column>
            <p:commandButton value="Details" onclick="tabVar.select(0);" />
        </p:column>
    </p:dataTable>
</p:tab>

当按下表格中的“详细信息”按钮时,我想在第一个选项卡中显示所选学生。我怎样才能做到这一点?

【问题讨论】:

    标签: jsf primefaces


    【解决方案1】:

    Primefaces tabview 有 activeIndex 属性,你可以绑定到 bean 变量:

    <p:tabView id="tabView" activeIndex="#{studentMB.tabindex}">
    

    在每个 commandButton 操作中,您传递值以确定学生。

    <p:commandButton update=":tabView" value="Details" actionListener="#{studentMB.handUpdate(student)}" />
    

    豆子:

    public void handUpdate(StudentType stValue){
            // get student detail
        }
    

    (对不起我的英语)

    【讨论】:

    • 我尝试并收到错误Cannot find component with identifier ":tabView" referenced from "j_idt18:tabView:studentsTable:0:j_idt117
    • 你必须设置 ":tabView"
    • 我找到了""j_idt18:tabView",你必须为tabView的父级设置ID,然后你取:update=":parent_id:tabView"
    猜你喜欢
    • 2018-11-27
    • 2015-02-04
    • 1970-01-01
    • 2016-04-13
    • 2013-09-28
    • 2014-09-17
    • 1970-01-01
    相关资源
    最近更新 更多