开发者

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

开发者 https://www.devze.com 2023-02-26 03:22 出处:网络
I have a page named Tabview1 which composed of tabview. Tabview1.xhtml: <p:tabView> <p:tab title=\"1\">

I have a page named Tabview1 which composed of tabview.

   Tabview1.xhtml:
       <p:tabView>
            <p:tab title="1">
               <ui:include src="/Apanel.xhtml"/>开发者_如何学JAVA
            </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 ?


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.


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

精彩评论

暂无评论...
验证码 换一张
取 消