primefaces: Menu : MenuItem oncomplete script is not called if no action is specified

Describe the bug

Hi ! Since the Primefaces 13 release, if you define a menu with a menuitem with an oncomplete script and you don’t define a bean action method, the oncomplete script is not called.

Reproducer

<p:menu>  
    <p:menuitem value="Without action" oncomplete="console.log('Oncomplete not called')" />  
    <p:menuitem value="With action" action="#{testView.init()}" oncomplete="console.log('Oncomplete called')" />  
</p:menu>

Expected behavior

The oncomplete script should be called independently of the action method.

PrimeFaces edition

Elite

PrimeFaces version

13.0.0 and 14.0.0-SNAPSHOT

Theme

No response

JSF implementation

All

JSF version

4.0

Java version

11

Browser(s)

All

About this issue

  • Original URL
  • State: closed
  • Created 10 months ago
  • Comments: 28 (24 by maintainers)

Commits related to this issue

Most upvoted comments

Yes only PanelGrid we are leaving as its so widely used but DataGrid and DataView etc you should switch to a responsive layout! It actually works better than the TR/TD layout that is deprecated.

I have removed that warning in 13.0.4

decided to close the PR as its currently by design and we decided in the past to not log warnings for each of those nonsense-combinations

nevertheless i enhanced the code/“submitting” detection a bit

@brivalin The workaround for now is to use listener="#{controller.noop()}" like you have done.

@jepsar yes I think its this commit: https://github.com/primefaces/primefaces/commit/9d16e0fd0b01257101a0f73297ea3b6abc4a83f2

specifically…

boolean isLink = LangUtils.isNotBlank(menuitem.getUrl()) || LangUtils.isNotBlank(menuitem.getOutcome());
boolean isCommand = LangUtils.isNotBlank(menuitem.getCommand());
if (!isCommand && menuitem instanceof UIMenuItem) {
       UIMenuItem uim = (UIMenuItem) menuitem;
        isCommand = uim.getActionExpression() != null || uim.getActionListeners().length > 0;
}

This is the line: isCommand = uim.getActionExpression() != null || uim.getActionListeners().length > 0;