javascript - PrimeFaces 设置 tabView 始终查看第一个选项卡

标签 javascript jsf-2 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>

当我第一次按下显示此对话框的按钮时:

  • 它正确显示第一个选项卡。
  • 我将选项卡更改为第二个
  • 我关闭 View
  • 我再次打开 View
  • 它位于第二个选项卡上,而不是第一个选项卡上。

如何将 View 设置为始终位于第一个选项卡中?

最佳答案

您可以通过手动选择对话框中显示的第一个选项卡来实现此目的。 IE。为 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">

关于javascript - PrimeFaces 设置 tabView 始终查看第一个选项卡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19319448/

相关文章:

jsf - Tomcat 7 链接错误 : loader constraint violation

java - Primefaces 数据表 : what 'onRowSelectUpdate="display"' means?

jsf-2 - Primefaces:如何获取数据表列过滤器组件

jsf - 如何在 PrimeFaces 5.0 中使用 tabView 获取动态选项卡名称和数据?

javascript - 自定义对象上的 Ember 绑定(bind)

javascript - 谷歌地图javascript自定义表面

Javascript "global"变量问题

JSF 2 全局异常处理,导航到错误页面未发生

java - Primefaces/JSF 按钮的操作处理程序不会触发相关 bean 的方法

javascript - 基本的类似 JSON 的对象结构?