The p:menuBar
and it's p:menuItem
s 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:menuItem
s 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.