当selectOneMenu的值发生变化时,我正在努力调用一个方法:下面是代码 - 当值改变时不调用该方法。
我正在使用Wildfly 9.0.1和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> ...
以下是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;
}
}