2013-04-18 43 views
-3

我使用p:tabMenu組件。我有4菜單項,每個重定向到一個不同的jsf頁面,但問題是頁面返回時不更改活動索引和活動索引保持與初始值爲0相同。我卡在p:Tabmenu幫助請

此代碼位於模板頁面所有

<h:form> 
    <p:tabMenu activeIndex="0"> 
     <p:menuitem value="Home" url="Menu.jsf" icon="ui-icon-star" /> 
     <p:menuitem value="Fabricants" url="/pagess/pagesFabricant/Fabricant.jsf" icon="ui-icon-wrench" /> 
     <p:menuitem value="Composants" url="/pagess/pagesComposant/Composant.jsf" icon="ui-icon-search" /> 
     <p:menuitem value="Dossier d'equivalence" url="DEQ.jsf" icon="ui-icon-document" /> 
    </p:tabMenu> 
    </h:form> 

頁我怎樣才能解決這個問題知道將要自動改變?

我紙盤託管bean那不行

public class LoginBean { 
    private int activeindex=0; 
public int getActiveindex() { 
     return activeindex; 
    } 

    public void setActiveindex(int activeindex) { 
     this.activeindex = activeindex; 
    } 

    public void Dirige(int a){ 

     activeindex=a; 
    }}.. 



<p:tabMenu activeIndex="#{loginBean.activeindex}" > 
     <p:menuitem value="Home" url="Menu.jsf" icon="ui-icon-star" action="#{loginBean.Dirige(0)}"/> 
     <p:menuitem value="Fabricants" url="/pagess/pagesFabricant/Fabricant.jsf" icon="ui-icon-wrench" action="#{loginBean.Dirige(1)}"/> 
    </p:menuitem> 

它也沒有工作

我嘗試添加更新=「@一切」爲everu菜單項。它是相同:(


我忘了告訴你。這部分是模板頁面..所有網頁上使用此模板 ! 當頁面上braowser收取的問題它以財產的模板,在模板 代碼

<h:form> 
    <p:tabMenu activeIndex="0"> 
     <p:menuitem value="Home" url="Menu.jsf" icon="ui-icon-star" /> 
     <p:menuitem value="Fabricants" url="/pagess/pagesFabricant/Fabricant.jsf" icon="ui-icon-wrench" /> 
     <p:menuitem value="Composants" url="/pagess/pagesComposant/Composant.jsf" icon="ui-icon-search" /> 
     <p:menuitem value="Dossier d'equivalence" url="DEQ.jsf" icon="ui-icon-document" /> 
    </p:tabMenu> 
    </h:form> 

它顯示0活躍指數,對於我的事情所有的頁面重定向不同步活動索引.. 請問有沒有任何的解決辦法

回答

0

我覺得只能更新組件樹裏面的action方法。

您可以在動作方法中動態修改組件並同樣設置活動索引。

這裏是tabMenu組件api的進一步參考。

http://www.primefaces.org/docs/api/3.5/org/primefaces/component/tabmenu/TabMenu.html

public void getFooClientId(int activeIndex) { 
    FacesContext context = FacesContext.getCurrentInstance(); 
    UIViewRoot root = context.getViewRoot(); 

    final String componentId = "foo"; 
    UIComponent c = findComponent(root, componentId); 
    TabMenu t = (TabMenu)c; 
    t.setActiveIndex(activeIndex); 


    } 

    /** 
    * Finds component with the given id 
    */ 
    private UIComponent findComponent(UIComponent c, String id) { 
    if (id.equals(c.getId())) { 
     return c; 
    } 
    Iterator<UIComponent> kids = c.getFacetsAndChildren(); 
    while (kids.hasNext()) { 
     UIComponent found = findComponent(kids.next(), id); 
     if (found != null) { 
     return found; 
     } 
    } 
    return null; 
    }