MenuBar update not calling getModel method

UI Components for JSF
Post Reply
joadarpe
Posts: 5
Joined: 11 Apr 2011, 23:58

27 Oct 2011, 18:08

Hi every one,

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 MenuBean is SessionScoped
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 :cry:

Code: Select all

<h:form id="frmMenu">
     <p:commandButton value="reload"  update="frmMenu"   />
     <p:menubar id="menu"  binding="#{menuBean.menuBar}" />
</h:form>
I've also tried using the FindComponent to change the model but still not working.... :cry:

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());
       }
}
Any clues??

Thanks

wobblycogs
Posts: 47
Joined: 19 Apr 2010, 19:09
Location: Gloucester, UK

28 Oct 2011, 14:02

I don't have a solution but I can confirm that I'm seeing the same thing. If an update is requested on a model backed MenuBar it fails to render and so just vanishes from the page with a full refresh being the only way to get it back. I asked about it but got no replies.
PrimeFaces 3.0.1, Mojarra 2.1.3, GlassFish 3.1.1, Netbeans 7.0, Firefox 7

joadarpe
Posts: 5
Joined: 11 Apr 2011, 23:58

28 Oct 2011, 17:33

Well, I've found that I miss one steep using binding. The method used to build the menuBar object was like this:

Code: Select all

menuBar = new Menubar();
menuBar.setModel(getModel());
// I wasn't building the menuBar with this:
menuBar.buildMenuFromModel();
So now it's working but the only one problem is that using binding makes it to call getter method any time you make any request... :? so you're calling it even if you don't need it..

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 30 guests