I'm usign Mojarra 2.1.23 and Primefaces 3.5. I'm trying to make this code work, but for some reason I can't get the listener to be invoked.
<h:form id="menu" >
<p:growl id="messages" autoUpdate="true" showDetail="true" />
<p:panelMenu>
<p:submenu label="Ajax Menuitems">
<p:menuitem value="#{MenuController.test}"
actionListener="#{MenuController.save}" ajax="true"
update="messages" />
<p:menuitem value="Update" actionListener="#{MenuController.save}"
update="messages" />
</p:submenu>
</p:panelMenu>
</h:form>
MenuController
is a session scoped bean managed by Spring 3 and even its properties are properly displayed on the same xhtml (button shows the text "Save").
The MenuController
class is as follows:
public class MenuController() implements Serializable{
public static Logger log;
public String test="Save";
public MenuController() {
log = LoggerFactory.getLogger(this.getClass());
log.debug("Hello MenuController.");
}
public void save(ActionEvent event) {
addMessage("Data saved");
log.debug(" saving");
}
public void addMessage(String summary) {
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO,
summary, null);
FacesContext.getCurrentInstance().addMessage(null, message);
}
//getters and setters...
}
I'm also using facelets, the following is Layout.xhtml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title><ui:insert name="title" /></title>
</h:head>
<h:body>
<div id="layout">
<table>
<tr>
<td>
<div id="menu">
<ui:include src="menu.xhtml"/>
</div>
</td>
<td>
<div id="content">
<ui:insert name="content">
</ui:insert>
</div>
</td>
</tr>
<tr>
<td>
<div id="footer">
<p><a href="#">© Footer</a></p>
</div>
</td>
</tr>
</table>
</div>
When I click the menu entry, the method is not being called.