Page 1 of 1

Why can I not add an action to a pr:menu menuitem?

Posted: 30 Jun 2015, 06:00
by RElliott
I added the following code to my Rio template menu:

Code: Select all

<form id="menu-form">
    <pr:menu id="rm_test">
        <p:menuitem
            id="rm_logout"
            value="Logout"
            icon="icon-locked57 Fs16"
            action="#{elisSession.logout}"
            ajax="false" />
    </pr:menu>
</form>
Unfortunately, when I accessed my welcome page, I received the following error:

Code: Select all

2015-06-29T22:51:24.534-0500|Severe: Error Rendering View[/welcome.xhtml]
javax.faces.FacesException: MenuItem must be inside a form element
	at org.primefaces.rio.component.menu.RioMenuRenderer.encodeMenuItem(RioMenuRenderer.java:198)
	at org.primefaces.rio.component.menu.RioMenuRenderer.encodeElement(RioMenuRenderer.java:72)
	at org.primefaces.rio.component.menu.RioMenuRenderer.encodeElements(RioMenuRenderer.java:51)
	at org.primefaces.rio.component.menu.RioMenuRenderer.encodeMarkup(RioMenuRenderer.java:41)
	at org.primefaces.component.menu.BaseMenuRenderer.encodeEnd(BaseMenuRenderer.java:113)

Re: Why can I not add an action to a pr:menu menuitem?

Posted: 30 Jun 2015, 08:13
by mert.sincan
Please try with "<h:form>".

Re: Why can I not add an action to a pr:menu menuitem?

Posted: 30 Jun 2015, 10:47
by RElliott
That was too easy. Thanks!

Re: Why can I not add an action to a pr:menu menuitem?

Posted: 30 Jun 2015, 16:21
by mert.sincan
Glad to hear, thanks!