second call on p:menuitem doesn't produce any output

UI Components for JSF
Post Reply
mulivieri
Posts: 1
Joined: 29 Nov 2022, 16:29

29 Nov 2022, 18:27

Hello team,

I'm involved in a migration of a Java Web Application from Primefaces 6.2 to Primefaces 8.0.
I resolved all issues following official migration guides:
https://primefaces.github.io/primefaces ... nguide/7_0
and
https://primefaces.github.io/primefaces ... nguide/8_0

In the end the application is working properly in all parts 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 (IBM Liberty Server, jdk1.8.0_91) neither in browser console (Google Chrome Version 107.0.5304.107 (Official Build) (64-bit)).
This wasn't happening on Primefaces 6.2.
All the components involved are the same before and after the migration.

Please could you help me?
What have I to post to help you to understand what's happening?

Code as follow:

list.xhtml -> the ui:composition that contains the p:menubutton component.
dialog.xhtml -> the ui:composition rendered after invoke actions setted on each DefaultMenuItem.
SomeBean.java -> the class that initialize the model used into p:menubutton component.

****list.xhtml****

Code: Select all

<ui:composition 	
		xmlns="http://www.w3.org/1999/xhtml"
		xmlns:h="http://java.sun.com/jsf/html"
		xmlns:f="http://java.sun.com/jsf/core"
		xmlns:ui="http://java.sun.com/jsf/facelets"
		xmlns:fn="http://java.sun.com/jsp/jstl/functions"
		xmlns:p="http://primefaces.org/ui">
		
	<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****

Code: Select all

<ui:composition 	
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:fn="http://java.sun.com/jsp/jstl/functions"
	xmlns:p="http://primefaces.org/ui">

	<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****

Code: Select all

@Named(ConstantsWeb.MBean.SOME_BEAN)
@ViewScoped
public class SomeBean extends AbstractBean {

	private transient MenuModel model;
	
	public MenuModel initModel() {
	
\\	[...some code...]
	
				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() {
	
	\\	[...do something...]
	
	}
	
	public void destroyBeanViewScope(final String... yourBeanArray) {
		FacesHelper.destroyBeanViewScope(yourBeanArray);
		renderResponse = false;
		FacesHelper.update(someForm:idDlgGeneric);
	}
}

****SomeOtherBean.java****

Code: Select all

@Named(ConstantsWeb.MBean.SOME_OTHER_BEAN)
@ViewScoped
public class SomeOtherBean extends AbstractBean {

	public void save() {
	
	\\	[...do something...]
	
	}

}

Melloware
Posts: 3717
Joined: 22 Apr 2013, 15:48

30 Nov 2022, 16:27

If you put together a PrimeFaces Test reproducer it would be easier for us to debug: https://github.com/primefaces/primefaces-test
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 41 guests