I need to change some items from a submenu, so I implemented it on getModel method... And I use a commandButton to update the menubar so it calls the getModel method... but its not doing it.. the method is called only when the page is reloaded (F5)
Basically I have something like this:
Code: Select all
<h:form id="frmMenu">
<p:commandButton value="reload" update="frmMenu" />
<p:menubar id="menu" model="#{menuBean.model}" />
</h:form>
the getModel() method has the logic to change the model (MenuModel Object) but the method is not been called when the button is clicked... the curious thing is the ajax request is been done....
I've tried changing it for a binding ... and it does call the getMenuBar() method every time I need... the only one problem is that the menuBar is not been rendered on view
Code: Select all
<h:form id="frmMenu">
<p:commandButton value="reload" update="frmMenu" />
<p:menubar id="menu" binding="#{menuBean.menuBar}" />
</h:form>
Code: Select all
<h:form id="frmMenu">
<p:commandButton value="reload" update="frmMenu" actionListener="#{menuBean.changeMenu}" process="@this" />
<p:menubar id="menu" model="#{menuBean.model}" />
</h:form>
Code: Select all
public changeMenu() {
Menubar menuBarView = (Menubar) FacesContext.getCurrentInstance().getViewRoot().findComponent("frmMenu:menu");
if (menuBarView != null) {
menuBarView.setModel(getModel());
}
}
Thanks