If you want to do it. You cannot use the url in p:menuitem , because we must call the tabulation method before going to the prefil.xhtml page. If you use url , the method will be called after going to the prefil.xhtml page.
First, you can use the p:menuitem action field, the method returns the address you want to skip:
<p:menubar autoSubmenuDisplay="true"> <p:submenu label="Perfil"> <p:menuitem value="Editar" action="#{some.editar}" ajax="false"/> <p:menuitem value="Ver" action="#{some.ver}" ajax="false" /> </p:submenu> </p:menubar>
These two methods do something to modify tabindex as follows:
public String editar() { tabindex = 0; return "verPerfil"; } public String ver() { tabindex = 1; return "verPerfil"; }
Then p:tabView has an attribute called activeIndex . This is the index of the active tab, the default value is 0 . So you can do the following:
<p:tabView dynamic="true" activeIndex="#{some.tabindex}" > <p:tab id="ver" title="Ver perfil"> <ui:include src="verPerfil.xhtml" /> </p:tab> <p:tab id="editar" title="Editar perfil"> <ui:include src="editarPerfil.xhtml" /> </p:tab> </p:tabView>
Then each menu item activates the corresponding tab.
Fishgel
source share