2013-10-11 34 views
0

我有一個TabView的了這樣的:PrimeFaces設置TabView的查看總是第一個選項卡

<p:dialog id="dialog" header="Details" widgetVar="ctrDialog" resizable="true" width="450px" height="500px"> 
      <p:tabView orientation="top" id="display" dynamic="true" > 
       <p:tab title="Operation"> 
        <h:panelGrid id="mainPage" columns="2" cellpadding="10"> 
         <f:facet name="header"> 
          <p:graphicImage value="/resources/images/#{imagesBean.getImageName(errorContractBean.selectedContract.producttype)}.png" /> 
         </f:facet> 

         <h:outputText value="#{bundle['emir_PRODUCTTYPE']}:" /> 
         <h:outputText value="#{errorContractBean.selectedContract.producttype}" style="font-weight:bold"/> 

         <h:outputText value="#{bundle['emir_PRODUCTSUBTYPE']}:" /> 
         <h:outputText value="#{errorContractBean.selectedContract.productsubtype}" style="font-weight:bold"/> 

         <h:outputText value="#{bundle['emir_PORTFOLIO']}:" /> 
         <h:outputText value="#{errorContractBean.selectedContract.portfolio}" style="font-weight:bold"/> 

         <h:outputText value="#{bundle['emir_TRADENUMBER']}:" /> 
         <h:outputText value="#{errorContractBean.selectedContract.tradenumber}" style="font-weight:bold"/> 

         <h:outputText value="#{bundle['emir_EVENTTYPE']}:" /> 
         <h:outputText value="#{errorContractBean.selectedContract.eventtype}" style="font-weight:bold"/> 

         <h:outputText value="#{bundle['emir_PARENTTRADENUMBER']}:" /> 
         <h:outputText value="#{errorContractBean.selectedContract.parenttradenumber}" style="font-weight:bold"/> 

         <h:outputText value="#{bundle['emir_COUNTERPART']}:" /> 
         <h:outputText value="#{errorContractBean.selectedContract.counterpart}" style="font-weight:bold"/> 

         <h:outputText value="#{bundle['emir_EVENTDATE']}:" /> 
         <h:outputText value="#{errorContractBean.selectedContract.fmteventdate}" style="font-weight:bold"/> 

         <h:outputText value="#{bundle['emir_TRADEDATE']}:" /> 
         <h:outputText value="#{errorContractBean.selectedContract.fmttradedate}" style="font-weight:bold"/> 

         <h:outputText value="#{bundle['emir_SDR']}:" /> 
         <h:outputText value="#{errorContractBean.selectedContract.sdr}" style="font-weight:bold"/> 

         <h:outputText value="#{bundle['emir_USI']}:" /> 
         <h:outputText value="#{errorContractBean.selectedContract.usi}" style="font-weight:bold"/> 
        </h:panelGrid> 
       </p:tab> 
       <p:tab title="First Leg" rendered="#{errorContractBean.hasfirstleg}"> 
        <h:panelGrid id="leg1" columns="2" cellpadding="4"> 
         <h:outputText value= "#{bundle['emir_OTCFIXVAR']}:"/>     <h:outputText value= "#{errorContractBean.firstleg.fixvar}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCSIGN']}:"/>      <h:outputText value= "#{errorContractBean.firstleg.sign}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCSTARTDATE']}:"/>    <h:outputText value= "#{errorContractBean.firstleg.fmtstartdate}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCENDDATE']}:"/>     <h:outputText value= "#{errorContractBean.firstleg.fmtenddate}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCPAYCURRENCY']}:"/>    <h:outputText value= "#{errorContractBean.firstleg.paycurrency}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCNOTIONAL']}:"/>     <h:outputText value= "#{errorContractBean.firstleg.notional}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCRATE']}:"/>      <h:outputText value= "#{errorContractBean.firstleg.rate==0 ? 'N/A' : errorContractBean.firstleg.rate}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCFREQUENCY']}:" />    <h:outputText value= "#{errorContractBean.firstleg.frequency}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCFREQUENCYUNIT']}:" />   <h:outputText value= "#{errorContractBean.firstleg.frequencyunit}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCFREQUENCYMULTIPLIER']}:" />  <h:outputText value= "#{errorContractBean.firstleg.frequencymultiplier==0 ? 'N/A' : errorContractBean.firstleg.frequencymultiplier}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCINDEXNAME']}:"/>    <h:outputText value= "#{errorContractBean.firstleg.indexname}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCMARGIN']}:"/>     <h:outputText value= "#{errorContractBean.firstleg.margin}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCOPTIONTYPE']}:"/>    <h:outputText value= "#{errorContractBean.firstleg.optiontype}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCOPTIONMATURITY']}:"/>   <h:outputText value= "#{errorContractBean.firstleg.optionmaturity}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCOPTIONCASHDELIVERY']}:"/>  <h:outputText value= "#{errorContractBean.firstleg.optioncashdelivery}" style="font-weight:bold"/> 
         <h:outputText value= "In arrears:"/>         <h:outputText value= "#{errorContractBean.firstleg.inareas==0 ? 'N/A' : 'true'}" style="font-weight:bold"/> 
         <h:outputText value= "Day Convention:"/>        <h:outputText value= "#{errorContractBean.firstleg.dayconvention}" style="font-weight:bold"/> 
         <h:outputText value= "Call Curr.:"/>         <h:outputText value= "#{errorContractBean.firstleg.callcurrency}" style="font-weight:bold"/> 
         <h:outputText value= "Call Maturity:"/>         <h:outputText value= "#{errorContractBean.firstleg.callmaturity}" style="font-weight:bold"/> 
         <h:outputText value= "Call Amount:"/>         <h:outputText value= "#{errorContractBean.firstleg.callamount}" style="font-weight:bold"/> 
         <h:outputText value= "Put Curr.:"/>          <h:outputText value= "#{errorContractBean.firstleg.putcurrency}" style="font-weight:bold"/> 
         <h:outputText value= "Put Maturity:"/>         <h:outputText value= "#{errorContractBean.firstleg.putmaturity}" style="font-weight:bold"/> 
         <h:outputText value= "Put Amount:"/>         <h:outputText value= "#{errorContractBean.firstleg.putamount}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCSTRIKE']}:"/>     <h:outputText value= "#{errorContractBean.firstleg.strike}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCOPTIONEXETYPE']}:"/>   <h:outputText value= "#{errorContractBean.firstleg.exercisemode}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCQTYUNIT']}:"/>     <h:outputText value= "#{errorContractBean.firstleg.quantityunit}" style="font-weight:bold"/> 
        </h:panelGrid> 
       </p:tab> 

       <p:tab title="Second Leg" rendered="#{errorContractBean.hassecondleg}"> 
        <h:panelGrid id="leg2" columns="2" cellpadding="4"> 
         <h:outputText value= "#{bundle['emir_OTCFIXVAR']}:"/>     <h:outputText value= "#{errorContractBean.secondleg.fixvar}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCSIGN']}:"/>      <h:outputText value= "#{errorContractBean.secondleg.sign}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCSTARTDATE']}:"/>    <h:outputText value= "#{errorContractBean.secondleg.fmtstartdate}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCENDDATE']}:"/>     <h:outputText value= "#{errorContractBean.secondleg.fmtenddate}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCPAYCURRENCY']}:"/>    <h:outputText value= "#{errorContractBean.secondleg.paycurrency}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCNOTIONAL']}:"/>     <h:outputText value= "#{errorContractBean.secondleg.notional}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCRATE']}:"/>      <h:outputText value= "#{errorContractBean.secondleg.rate==0 ? 'N/A' : errorContractBean.secondleg.rate}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCFREQUENCY']}:" />    <h:outputText value= "#{errorContractBean.secondleg.frequency}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCFREQUENCYUNIT']}:" />   <h:outputText value= "#{errorContractBean.secondleg.frequencyunit}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCFREQUENCYMULTIPLIER']}:" />  <h:outputText value= "#{errorContractBean.secondleg.frequencymultiplier==0 ? 'N/A' : errorContractBean.secondleg.frequencymultiplier}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCINDEXNAME']}:"/>    <h:outputText value= "#{errorContractBean.secondleg.indexname}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCMARGIN']}:"/>     <h:outputText value= "#{errorContractBean.secondleg.margin}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCOPTIONTYPE']}:"/>    <h:outputText value= "#{errorContractBean.secondleg.optiontype}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCOPTIONMATURITY']}:"/>   <h:outputText value= "#{errorContractBean.secondleg.optionmaturity}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCOPTIONCASHDELIVERY']}:"/>  <h:outputText value= "#{errorContractBean.secondleg.optioncashdelivery}" style="font-weight:bold"/> 
         <h:outputText value= "In arrears:"/>         <h:outputText value= "#{errorContractBean.secondleg.inareas==0 ? 'N/A' : 'true'}" style="font-weight:bold"/> 
         <h:outputText value= "Day Convention:"/>        <h:outputText value= "#{errorContractBean.secondleg.dayconvention}" style="font-weight:bold"/> 
         <h:outputText value= "Call Curr.:"/>         <h:outputText value= "#{errorContractBean.secondleg.callcurrency}" style="font-weight:bold"/> 
         <h:outputText value= "Call Maturity:"/>         <h:outputText value= "#{errorContractBean.secondleg.callmaturity}" style="font-weight:bold"/> 
         <h:outputText value= "Call Amount:"/>         <h:outputText value= "#{errorContractBean.secondleg.callamount}" style="font-weight:bold"/> 
         <h:outputText value= "Put Curr.:"/>          <h:outputText value= "#{errorContractBean.secondleg.putcurrency}" style="font-weight:bold"/> 
         <h:outputText value= "Put Maturity:"/>         <h:outputText value= "#{errorContractBean.secondleg.putmaturity}" style="font-weight:bold"/> 
         <h:outputText value= "Put Amount:"/>         <h:outputText value= "#{errorContractBean.secondleg.putamount}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCSTRIKE']}:"/>     <h:outputText value= "#{errorContractBean.secondleg.strike}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCOPTIONEXETYPE']}:"/>   <h:outputText value= "#{errorContractBean.secondleg.exercisemode}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCQTYUNIT']}:"/>     <h:outputText value= "#{errorContractBean.secondleg.quantityunit}" style="font-weight:bold"/> 
        </h:panelGrid> 
       </p:tab> 

       <p:tab title="Near Leg" rendered="#{errorContractBean.hasnearleg}"> 
        <h:panelGrid id="near" columns="2" cellpadding="4"> 
         <h:outputText value= "#{bundle['emir_OTCCURRENCYBUY']}:"/>    <h:outputText value= "#{errorContractBean.nearleg.currencybuy}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCCURRENCYSELL']}:"/>    <h:outputText value= "#{errorContractBean.nearleg.currencysell}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCPRICEFACTOR']}:"/>    <h:outputText value= "#{errorContractBean.nearleg.pricefactor}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCSWAPRATE']}:" />    <h:outputText value= "#{errorContractBean.nearleg.swaprate}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCVOLUMEBUY']}:" />    <h:outputText value= "#{errorContractBean.nearleg.volumebuy}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCVOLUMESELL']}:" />    <h:outputText value= "#{errorContractBean.nearleg.volumesell}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCTIPOPRODOTTO']}:"/>    <h:outputText value= "#{errorContractBean.nearleg.tipoprodotto}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCAMMONTAREINTERESSI']}:"/>  <h:outputText value= "#{errorContractBean.nearleg.ammontareinteressi}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCCODICECONTRATTO']}:"/>   <h:outputText value= "#{errorContractBean.nearleg.codicecontratto}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCDATACONTRATTO']}:"/>   <h:outputText value= "#{errorContractBean.nearleg.datacontratto}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCORACONTRATTO']}:"/>    <h:outputText value= "#{errorContractBean.nearleg.oracontratto}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCDEALTRANSREFERENCE']}:"/>  <h:outputText value= "#{errorContractBean.nearleg.dealtransreference}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCDEALINDEX']}:"/>    <h:outputText value= "#{errorContractBean.nearleg.dealindex}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCTRADERID']}:"/>     <h:outputText value= "#{errorContractBean.nearleg.traderid}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCIDCONTROPARTE']}:"/>   <h:outputText value= "#{errorContractBean.nearleg.idcontroparte}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCNOMECONTROPARTE']}:"/>   <h:outputText value= "#{errorContractBean.nearleg.nomecontroparte}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCDATAINIZIOREGOLAMENTO']}:"/> <h:outputText value= "#{errorContractBean.nearleg.datainizioregolamento}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCDATAREGOLAMENTO']}:"/>   <h:outputText value= "#{errorContractBean.nearleg.dataregolamento}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCSPOTPRICEFACTOR']}:"/>   <h:outputText value= "#{errorContractBean.nearleg.spotpricefactor}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCSPOTDATE']}:"/>     <h:outputText value= "#{errorContractBean.nearleg.spotdate}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCVSEURPRICEFACTOR']}:"/>   <h:outputText value= "#{errorContractBean.nearleg.vseurpricefactor}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCBASISPOINT']}:"/>    <h:outputText value= "#{errorContractBean.nearleg.basispoint}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCUSI']}:"/>      <h:outputText value= "#{errorContractBean.nearleg.usi}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCSDR']}:"/>      <h:outputText value= "#{errorContractBean.nearleg.sdr}" style="font-weight:bold"/> 
        </h:panelGrid> 
       </p:tab> 

       <p:tab title="Far Leg" rendered="#{errorContractBean.hasfarleg}"> 
        <h:panelGrid id="far" columns="2" cellpadding="4"> 
         <h:outputText value= "#{bundle['emir_OTCCURRENCYBUY']}:"/>    <h:outputText value= "#{errorContractBean.farleg.currencybuy}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCCURRENCYSELL']}:"/>    <h:outputText value= "#{errorContractBean.farleg.currencysell}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCPRICEFACTOR']}:"/>    <h:outputText value= "#{errorContractBean.farleg.pricefactor}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCSWAPRATE']}:" />    <h:outputText value= "#{errorContractBean.farleg.swaprate}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCVOLUMEBUY']}:" />    <h:outputText value= "#{errorContractBean.farleg.volumebuy}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCVOLUMESELL']}:" />    <h:outputText value= "#{errorContractBean.farleg.volumesell}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCTIPOPRODOTTO']}:"/>    <h:outputText value= "#{errorContractBean.farleg.tipoprodotto}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCAMMONTAREINTERESSI']}:"/>  <h:outputText value= "#{errorContractBean.farleg.ammontareinteressi}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCCODICECONTRATTO']}:"/>   <h:outputText value= "#{errorContractBean.farleg.codicecontratto}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCDATACONTRATTO']}:"/>   <h:outputText value= "#{errorContractBean.farleg.datacontratto}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCORACONTRATTO']}:"/>    <h:outputText value= "#{errorContractBean.farleg.oracontratto}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCDEALTRANSREFERENCE']}:"/>  <h:outputText value= "#{errorContractBean.farleg.dealtransreference}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCDEALINDEX']}:"/>    <h:outputText value= "#{errorContractBean.farleg.dealindex}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCTRADERID']}:"/>     <h:outputText value= "#{errorContractBean.farleg.traderid}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCIDCONTROPARTE']}:"/>   <h:outputText value= "#{errorContractBean.farleg.idcontroparte}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCNOMECONTROPARTE']}:"/>   <h:outputText value= "#{errorContractBean.farleg.nomecontroparte}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCDATAINIZIOREGOLAMENTO']}:"/> <h:outputText value= "#{errorContractBean.farleg.datainizioregolamento}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCDATAREGOLAMENTO']}:"/>   <h:outputText value= "#{errorContractBean.farleg.dataregolamento}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCSPOTPRICEFACTOR']}:"/>   <h:outputText value= "#{errorContractBean.farleg.spotpricefactor}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCSPOTDATE']}:"/>     <h:outputText value= "#{errorContractBean.farleg.spotdate}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCVSEURPRICEFACTOR']}:"/>   <h:outputText value= "#{errorContractBean.farleg.vseurpricefactor}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCBASISPOINT']}:"/>    <h:outputText value= "#{errorContractBean.farleg.basispoint}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCUSI']}:"/>      <h:outputText value= "#{errorContractBean.farleg.usi}" style="font-weight:bold"/> 
         <h:outputText value= "#{bundle['emir_OTCSDR']}:"/>      <h:outputText value= "#{errorContractBean.farleg.sdr}" style="font-weight:bold"/> 
        </h:panelGrid> 
       </p:tab> 

      </p:tabView> 
     </p:dialog> 

當我按下上顯示此對話框第一次按鍵:

  • 它顯示正確選擇第一個標籤。
  • 我更改選項卡到第二
  • 我關閉視圖
  • 我再次打開視圖
  • 這是第二個選項卡上,而不是第一個。

如何將視圖始終設置在第一個選項卡中?

回答

4

您可以通過手動選擇對話框顯示的第一個選項卡來實現此目的。即定義爲tabView一個widgetVar和處理onShow添加到對話:

<p:dialog onShow="ctrTabView.select(0);" id="dialog" header="Details" widgetVar="ctrDialog" resizable="true" width="450px" height="500px"> 
     <p:tabView widgetVar="ctrTabView" orientation="top" id="display" dynamic="true"> 
+0

偉人! :)))) –

+0

由於Primefaces 4.0使用PF()函數「PF('ctrTabView')。select(0)」 – 0x5a4d

相關問題