how to forward to a new page on click a tab of tabview

时光怂恿深爱的人放手 提交于 2020-01-15 15:47:09

问题


I have a page named Tabview1 which composed of tabview.

   Tabview1.xhtml:
       <p:tabView>
            <p:tab title="1">
               <ui:include src="/Apanel.xhtml"/>
            </p:tab>
            <p:tab title="2">
            </p:tab>
            <p:tab title="3">
            </p:tab>
        </p:tabView>

I want to forward to the page Tabview2.xhtml if click on the tab named 2.

Tabview2.xhtml:
       <p:tabView>
            <p:tab title="1">
            </p:tab>
            <p:tab title="2">
               <ui:include src="/Bpanel.xhtml"/>
            </p:tab>
            <p:tab title="3">
            </p:tab>
        </p:tabView>

Who can help me ?


回答1:


Tabview creates a list with one element for each tab. Every <li> contains an <a href="#j_idtXXX">. Create a script on your site that changes these links to Tabview2.xhtml. For example if you set the id of your tabview to "tabview":

jQuery("#tabview ul a").first().attr("href", /MyPortal/Tabview2.jsf?tab=0);

This would cause the first tab to lead to the new page, and select the right tab on that page if you have configured a viewparam and have activeIndex="#{controllerClass.activeIndex}" set on the tabview.

I'm in a rush now, so I only had time to write a short example, but if you have some skill with javascript, it should not be too hard.




回答2:


               <p:tabView>
            <p:tab title="Title1">
               <p:panel>  
                <ui:include src="tabView1.xhtml" />
               </p:panel>
            </p:tab>
            <p:tab title="Title 2">
                 <p:panel>  
                <ui:include src="tabView2.xhtml" />
                 </p:panel>
             </p:tab>           
        </p:tabView>


来源:https://stackoverflow.com/questions/5700503/how-to-forward-to-a-new-page-on-click-a-tab-of-tabview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!