0

I am struggling to call a method when a value of selectOneMenu is changed: below is the code - the method is not called when the value is changed.

I am using Wildfly 9.0.1 with PF 5.2.

<h:head>    
</h:head>

<h:body>
    <ui:composition>

        <ul class="nav nav-sidebar">
            <p:outputPanel style="float:center;margin-left: 33px"> 
                <h:outputLabel value="Hi there!"/>
            </p:outputPanel>
            <br/>


            <h:selectOneMenu value="#{leftMenuView.product}">

                <f:selectItems value="#{leftMenuView.products}"/>

                <f:ajax event="change" listener="#{leftMenuView.anyMethod}"/>

            </h:selectOneMenu> ...

Below is the Bean:

@ManagedBean
@ViewScoped
public class LeftMenuView implements Serializable{


    @EJB
    private PublicService publicService;

    private List<Product> products;

    private String product;



    @PostConstruct
    public void init() {

        this.products = publicService.getAllProducts(); 
    }

    public void anyMethod(AjaxBehaviorEvent event){
            System.out.println("method called?"); 
    }


    public String getProduct() {
        return product;
    }


    public void setProduct(String product) {
        this.product = product;
    }


    public void setProducts(List<Product> products) {
        this.products = products;
    }

    public List<Product> getProducts() {
        return products;
    }


}
LEK
  • 83
  • 2
  • 11

0 Answers0