2013-04-07 29 views
0

我有一個<p:tabView>與2個選項卡。第一個包含學生的詳細信息,第二個包含所有學生的表格。重新加載<p:tab>信息與<p:commandButton>行動

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

當按下表格中的「詳細信息」按鈕時,我想在第一個選項卡中顯示選定的學生。我怎樣才能做到這一點?

回答

1

Primefaces TabView的有activeIndex屬性,您可以綁定到豆變量:

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

(對不起,我的英語)

+0

我嘗試,我得到的錯誤'無法找到標識成分TabView的:::從「j_idt18引用 「TabView的」 studentsTable :0:j_idt117' – jaundavid 2013-04-08 06:18:38

+0

您必須設置「:tabView」 – 2013-04-08 06:21:10

+0

您可以從這裏得到:http://stackoverflow.com/questions/15807837/update-form-from-dialog/15807979#15807979 – 2013-04-08 06:23:15