I'm involved in a migration of a Java Web Application from Primefaces 6.2 to Primefaces 8.0. After resolving all issues as per official migration guides the application works properly except for the behavior on a p:menubutton component.
It regards a xhtml that produce a datatable where a column contains the DefaultMenuItem objects rendered by the attribute model on p:menubutton component.
ISSUE: First time I invoke one of the action setted into each DefaultMenuItem it works. The action opens a dialog but closing the dialog opened without doing a new submit, the second invocation doesn't produce any output. I can evaluate ajax request into the network tab of the browser console and nothing sounds wrong, it is equals to the first call. There're no errors in server console neither in browser console. This wasn't happening on Primefaces 6.2. All the components involved are the same before and after the migration.
Code as follow:
list.xhtml the ui:composition that contains the p:menubutton component
<ui:composition>
<h:form id="someForm" enctype="multipart/form-data">
<p:menuButton
model="#{SomeBean.model}"
id="idmenubutton"
icon="fa fa fa-ellipsis-v"
menuStyleClass="response-single-style"
title="some_title"
disabled="false"/>
</h:form>
</ui:composition>
dialog.xhtml the ui:composition rendered after invoke actions setted on each DefaultMenuItem
<ui:composition>
<p:importEnum type="some.path.SomeEnum" var="someEnum"/>
<p:dialog id="idDlgGeneric" header="some_header" styleClass="generic_pnlMaxWidth95"
widgetVar="dlgGeneric" modal="true" onShow="dlgOnShow(this.jqId);onShowForClosableDlg('dlgGeneric')"
responsive="true" fitViewport="true" showEffect="fade" hideEffect="fade" resizable="false" closable="true">
<p:panel rendered="true">
<p:panelGrid layout="grid" columns="2" columnClasses="ui-grid-col-6,ui-grid-col-6" styleClass="ui-panelgrid-blank">
<p:commandButton id="saveDlg" icon="fa fa-pencil" value="Save" action="#{SomeOtherBean.save}" styleClass="generic_width100"/>
<p:commandButton icon="fa fa-times" value="Close" action="#{SomeBean.destroyBeanViewScope('SomeOtherBean')}" onclick="PF('dlgGeneric').hide()" styleClass="generic_width100 uniqueCloseButton"/>
<p:defaultCommand target="@form:saveSomeOtherBean" scope="@form:idDlgGeneric" />
</p:panelGrid>
</p:panel>
</p:dialog>
</ui:composition>
SomeBean.java the class that initialize the model used into p:menubutton component
@Named(ConstantsWeb.MBean.SOME_BEAN)
@ViewScoped
public class SomeBean extends AbstractBean {
private transient MenuModel model;
public MenuModel initModel() {
model = new DefaultMenuModel();
final DefaultMenuItem title = DefaultMenuItem.builder()
.value("value_description")
.disabled(true)
.style("opacity:1;font-weight:bold;")
.build();
model.getElements().add(title);
for (final SomeEnum resp : responsSingle) {
Map<String, List<String>> map = new LinkedHashMap<String, List<String>>();
List<String> list = new ArrayList<String>();
list.add(String.valueOf(resp.getId()));
map.put("respId", list);
final DefaultMenuItem menuItem = DefaultMenuItem.builder()
.value(resp.getDisplayName())
.command("#{SomeBean.someMethod}")
.params(map)
.onstart("PF('statusDialog').show();")
.onsuccess("PF('statusDialog').hide();")
.update(someForm:idDlgGeneric)
.icon(resp.getIcon())
.disabled(false)
.build();
model.getElements().add(menuItem);
}
model.generateUniqueIds();
}
} else {
model = null;
}
return model;
}
public void someMethod() {
}
public void destroyBeanViewScope(final String... yourBeanArray) {
FacesHelper.destroyBeanViewScope(yourBeanArray);
renderResponse = false;
FacesHelper.update(someForm:idDlgGeneric);
}
}
Anyone could help me?