0

The p:menuBar and it's p:menuItems are generated at runtime. They render correctly and function perfectly with the exception that when any choice from the menu is clicked, nothing happens.

My index.xhtml is quite simple. It's just a p:tabView that composites my dataentry.xhtml in via a ui:include. The components on dataentry.xhtml are where the trouble is happening.

//dataentry.xhtml
<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
                xmlns:f="http://xmlns.jcp.org/jsf/core"
                xmlns:p="http://primefaces.org/ui">

    <h:form id="dataEntryForm">
        <p:menubar id="menuBar" binding="#{dataEntryBean.menuBar}" />
        <p:dashboard id="dashboard" binding="#{dataEntryBean.dashboard}"/>
    </h:form>

</ui:composition>

Here's the method that generates the p:menuBar. Again, all of this renders on the page correctly, it just doesn't do anything when you click on something.

    private @NotNull Menubar spawnMenuBar() {
        final MenuModel MODEL = new DefaultMenuModel();
        {
            final DefaultSubMenu SM = new DefaultSubMenu("Create New...", "ui-icon-circle-plus");
            Arrays.stream(Type.values()).forEach(CT -> {
                final String CT_ALT = CT.toInitialCaps();
                final DefaultMenuItem DMI = new DefaultMenuItem(CT_ALT + " Card");
                DMI.setId("createNew" + CT_ALT + "Type");
                DMI.setParam("TYPE", CT.name());
                DMI.setTitle("Creates a new " + CT_ALT + " type panel in the dashboard.");
                DMI.setCommand("#{dataEntryBean.addNewTypePanel(param.get('TYPE'))}");
                SM.addElement(DMI);
            });
            MODEL.addElement(SM);
        }
        {
            final DefaultSubMenu SM = new DefaultSubMenu("Global Actions...", "ui-icon-alert");
            // Implementation removed for brevity's sake...
            MODEL.addElement(SM);
        }
        final Menubar MENU = new Menubar();
        MENU.setModel(MODEL);
        return MENU;
    }

...and, finally, here's the method that all of those p:menuItems in the first p:subMenu are supposed to invoke.

public void addNewTypePanel(final String TYPE) {
    System.out.println("Method Call: addNewTypePanel(" + TYPE + ")");
    // Implementation removed for brevity's sake...
}

That println() in addNewTypePanel() never appears.

Bizarrely (and, I suspect, unrelated), the println() on the first line of this bean's constructor appears twice (and then a 3rd time when the appropriate tab in the p:tabView is loaded).

Any ideas?
doHope(HopeSeverity.VERY_HARD);


Edit #1: Based on Kukeltje's suggestion, I re-tested this code by commenting out the p:tabView entirely and copying the h:form from dataentry.xhmtl (see code block below). Unfortunately, the issue (issues?) were the same. Still no response on click, still see the bean's constructor being invoked three times.
// index.xhtml (alt version, same behavior)
    <f:view>
       <h:body>
           <h3>Some Text</h3>
           <h:form id="dataEntryForm">
               <p:menubar id="menuBar" binding="#{dataEntryBean.menuBar}" />
               <p:dashboard id="dashboard" binding="#{dataEntryBean.dashboard}"/>
           </h:form>
       </h:body>
   </f:view>

For clarification, the bean is @SessionScoped and @ManagedBean. I am testing all of this on Tomcat 8.0.33 with MyFaces 2.2.10.


Edit #2: Based on Kukeltje's request, stripped out some information that doesn't appear to be involved in the issue.
Darkly
  • 147
  • 2
  • 9
  • Does it work outside a tabview? Does it work when **not** using an include but directly in a page? – Kukeltje May 06 '16 at 06:26
  • Updated OP with the results of Kukeltje's suggestion. – Darkly May 06 '16 at 18:05
  • Right combination of scope and managedbean annotation? And please remove all the tabview and include stuff from the Q. It is not relevant and just creating possible noise – Kukeltje May 06 '16 at 18:21
  • I am - in no uncertain terms - **not** a JSF expert so, at best, my only answer to your question can be "I think so." :( – Darkly May 06 '16 at 18:38
  • See here: http://stackoverflow.com/questions/11986847/java-ee-6-javax-annotation-managedbean-vs-javax-inject-named-vs-javax-faces – Kukeltje May 06 '16 at 18:48
  • Oh, ok, I get what you meant now. Yes, both annotations are from the `javax.faces.bean` package. (Off topic: If I could get OWB working on Tomcat, I would very much like to be using `@Named` but that's an entirely different issue.) – Darkly May 06 '16 at 22:05

0 Answers0