I have the following Managed Bean:
import javax.faces.bean.ManagedBean;
@ManagedBean
public class MyBean {
public void mostrarCentroSeleccionado() {
System.out.println("Value changed");
}
}
And inside my .xhtml file the following selectOneMenu:
<p:selectOneMenu value="#{MyBean.centros.idcentro}" >
<p:ajax event="change" listener="#{MyBean.mostrarCentroSeleccionado}" />
<f:selectItem itemLabel="Seleccione un centro" itemValue="" />
<f:selectItems value="#{MyBean.centros}" />
</p:selectOneMenu>
When I run that code I get the following exception:
javax.el.MethodNotFoundException
Thanks in advance
If Holger's solutions works out, its fine.
BUT: It is horrible to start start a Java Class Name with lower case letter. You can start with a capital letter and JSF will manage it for you, so you can still use listener="#{myBean.mostrarCentroSeleccionado()}" If this does not meet your requirements you can use @ManagedBean(name = "myBean ") Instead of myBean you can choose what ever you want.
The problem was in the tag:
<p:ajax listener="#{MyBean.function()}"/>
The function must have "()" becouse I´m not taking the event.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.