jsf - Primefaces TabMenu selection is not changing -
i try build primefaces tabmenu web-page. displayed direct page want, won't set activeindex , still looks i'm still on main-page.
heres jsf-view (it's component, inserted page):
<ui:component> <div id="navigation"> <h:form id="navform"> <p:tabmenu activeindex="#{projectcockpit.pageid}"> <p:menuitem value="home" url="/mainpage.xhtml" actionlistener="#{projectcockpit.setpageid(0)}"> </p:menuitem> <p:menuitem value="projekte" url="/projects.xhtml"> <f:setpropertyactionlistener value="1" target="#{projectcockpit.pageid}" /> </p:menuitem> </p:tabmenu> </h:form> </div> </ui:component>
and here bean:
@managedbean(name = "projectcockpit") @sessionscoped public class projectcockpitbean implements serializable{ /** * */ private static final long serialversionuid = 8049539654282700741l; private int pageid; @postconstruct protected void init(){ pageid = 0; } public int getpageid() { return pageid; } public void setpageid(int pageid) { this.pageid = pageid; } }
for redirect page tabmenu, must use same code in 2 page this.
mainpage.xhtml
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui" template="/web-inf/template.xhtml"> <ui:define name="content"> <p:tabmenu activeindex="#{param.i}"> <p:menuitem value="overview" outcome="/mainpage.xhtml" icon="ui-icon-star"> <f:param name="i" value="0" /> </p:menuitem> <p:menuitem value="demos" outcome="/projects.xhtml" icon="ui-icon-search"> <f:param name="i" value="1" /> </p:menuitem> </p:tabmenu> //place mainpage code here <p:outputlabel value="mainpage code"/> </ui:define> </ui:composition>
projects.xhtml
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui" template="/web-inf/template.xhtml"> <ui:define name="content"> <p:tabmenu activeindex="#{param.i}"> <p:menuitem value="overview" outcome="/mainpage.xhtml" icon="ui-icon-star"> <f:param name="i" value="0" /> </p:menuitem> <p:menuitem value="demos" outcome="/projects.xhtml" icon="ui-icon-search"> <f:param name="i" value="1" /> </p:menuitem> </p:tabmenu> //place projects code here <p:outputlabel value="projects code"/> </ui:define> </ui:composition>
Comments
Post a Comment