I'm trying to implement some sort of menu with an accordionPanel, something like this:
xhtml:
Code: Select all
<h:form>
<p:accordionPanel id="menu" style="font-size: 12px" event="mouseover" autoHeight="false" tabChangeListener="#{menuStateBean.save}" activeIndex="#{menuStateBean.openTabIndex}">
<p:tab id="tab_0" title="#{men['mistareas']}">
<p:menu style="border: none">
<p:menuitem value="#{men['tarea1']}" url="#"/>
<p:menuitem value="#{men['tarea2']}" url="#"/>
<p:menuitem value="#{men['tarea3']}" url="#"/>
</p:menu>
</p:tab>
<p:tab id="tab_1" title="#{men['procesos']}">
<p:menu style="border: none">
<p:menuitem value="#{men['procesos1']}" url="#"/>
<p:menuitem value="#{men['procesos2']}" url="#"/>
</p:menu>
</p:tab>
</p:accordionPanel>
</h:form>
Code: Select all
@SessionScoped
@Named
public class MenuStateBean implements Serializable {
private int openTabIndex;
public MenuStateBean() {
}
//openTabIndex getter and setters
...
public void save(TabChangeEvent event) {
System.out.println(event.getTab().getId()+":"+openTabIndex);
}
}
The problem is that i can´t keep the active index into the backing bean instantly everytime i change the active tab, because menuStateBean.openTabIndex doesn't get updated. Is this the normal behaviour or i'm doing something wrong?
I realized that the ajax request doesn't send the active index param, only the name of the active tab is sent:
javax.faces.ViewState=-7492513648605843959:-4761100924695374686&javax.faces.partial.ajax=true&javax.faces.source=menu&javax.faces.partial.execute=menu&menu=menu&menu_tabChange=true&menu_newTab=tab_3
I think it would be easy if we could ajaxify the accordionPanel putting the element <p:ajax event="" process="" update=""/> into it.
thanks,
PD: i'm using primefaces 2.2.1 and mojarra 2.1