6.2 p:menuitem breaks legacy code

UI Components for JSF
Post Reply
setecastronomy
Posts: 5
Joined: 10 Feb 2012, 09:38

12 Apr 2019, 08:27

A legacy application was developed with Jsf 2.2 and PrimeFaces 5.2.
It was moved to a new application server with Jsf 2.3 and PrimeFaces 5.2 and it still worked as expected.
When PrimeFaces was upgraded to 6.2 the application crashed with the following error:
javax.faces.FacesException: MenuItem must be inside a form element
at org.primefaces.component.menu.BaseMenuRenderer.encodeMenuItem(BaseMenuRenderer.java:185)
at org.primefaces.component.tieredmenu.TieredMenuRenderer.encodeElements(TieredMenuRenderer.java:112)
at org.primefaces.component.tieredmenu.TieredMenuRenderer.encodeSubmenu(TieredMenuRenderer.java:174)
at org.primefaces.component.tieredmenu.TieredMenuRenderer.encodeElements(TieredMenuRenderer.java:131)
at org.primefaces.component.tieredmenu.TieredMenuRenderer.encodeMenu(TieredMenuRenderer.java:79)
Here is the cause:

Code: Select all

<p:menubar> 
  <p:submenu  label="#{bundle.ReportisticaTransiti_label}" >
            
...
<p:menuitem rendered="#{facesContext.externalContext.isUserInRole('aSpecificRole')}">
                <h:link outcome="aFlowStartNode" value="#{bundle.ConteggioTransitiVeicoli_label}" class="ui-menuitem-link ui-corner-all"/>
</p:menuitem>
So it seems that h:link cannot be nested inside p:menuitem any more but it is stated no where in the documentation.
Is it a bug or normal behavior ? Is there a way to make the previous menu work in 6.2 ?
That h:link is not easy to remove because it is the entry point for a flow...

Thanks
Filippo

tandraschko
PrimeFaces Core Developer
Posts: 3551
Joined: 03 Dec 2010, 14:11
Location: Bavaria, DE
Contact:

12 Apr 2019, 08:48

tried to put a form around your menu, like the exception says?
Always Bet On Prime (+ Extensions)!

Thomas Andraschko
PrimeFaces Developer | PrimeFaces Extensions Founder
Apache OpenWebBeans PMC | Apache DeltaSpike PMC | Apache MyFaces PMC

Personal Blog: http://tandraschko.blogspot.de/

setecastronomy
Posts: 5
Joined: 10 Feb 2012, 09:38

12 Apr 2019, 12:07

tandraschko wrote:
12 Apr 2019, 08:48
tried to put a form around your menu, like the exception says?
1 - I don't like to put a form around the menu, anyway I tried, but the link is not rendered correctly, if I remember well it is a relative url inside the same page

2 - When something worked with a previous version of Primefaces and now (6.2) it doesn't it may be due to a bug, or a specification compliant implementation. In any case I would like to read somewhere an official notice which warns about this potential problem with legacy code. I read the documentation and the migration guide but I didn't find anything.

Thanks
Filippo

tandraschko
PrimeFaces Core Developer
Posts: 3551
Joined: 03 Dec 2010, 14:11
Location: Bavaria, DE
Contact:

12 Apr 2019, 21:37

can you try 7.0?

JFYI: we need a form if the menuItem does a POST request (ajax or non-ajax), otherwise we don't search for a parent form.
You can't skip this behavior.

Otherwise please provide a simple reproducer, so we can check how the link is not rendered correctly?
Always Bet On Prime (+ Extensions)!

Thomas Andraschko
PrimeFaces Developer | PrimeFaces Extensions Founder
Apache OpenWebBeans PMC | Apache DeltaSpike PMC | Apache MyFaces PMC

Personal Blog: http://tandraschko.blogspot.de/

setecastronomy
Posts: 5
Joined: 10 Feb 2012, 09:38

15 Apr 2019, 11:53

I have just tried Primefaces 7.0 and it behaves like 6.2, the menuitem causes a crash.

Here is how it is rendered with Primefaces 5.2

Code: Select all

<li class="ui-menuitem ui-widget ui-corner-all" role="menuitem">
<a href="/FlowOne/notroot/brokenflow/brokenflow.xhtml?jftfdi=&amp;jffi=brokenflow&amp;jfwid=057d9b2cd80249a0a5f18198784e%3A1">brokenflow</a></li>
Putting a form around the menu here is how it is rendered in 7.0

Code: Select all

<li class="ui-menuitem ui-widget ui-corner-all" role="menuitem">
<a tabindex="-1" class="ui-menuitem-link ui-corner-all" href="#" onclick="PrimeFaces.ab({s:&quot;j_idt3:j_idt8&quot;,f:&quot;j_idt3&quot;});return false;">
<span class="ui-menuitem-text">Flow rotta2</span></a></li>
I can provide a very simple netbeans project but I cannot find a way to upload it

User avatar
Melloware
Posts: 996
Joined: 22 Apr 2013, 15:48

15 Apr 2019, 13:11

Simply create an issue here and upload the ZIP of your example: https://github.com/primefaces/primefaces/issues
PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 6.2.19 / PF Extensions 6.2.10

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 16 guests