0

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

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
juanmorschrott
  • 573
  • 5
  • 25

2 Answers2

0

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.

phe
  • 26
  • 6
  • If you know a little about PrimeFaces, you will understand that the point here is in one of two options. 1- Something missing or wrong at a xhtml tag or attribute. 2- A problem with the method to execute Anything else is just to put you in context. It´s not relevant or important. – juanmorschrott Jul 07 '16 at 17:39
0

The problem was in the tag:

<p:ajax listener="#{MyBean.function()}"/>

The function must have "()" becouse I´m not taking the event.

juanmorschrott
  • 573
  • 5
  • 25