java primefaces selectonemenu ajax侦听器不在对话框中工作
我正在尝试检索对话框中的Dropdown/selectonemenu的值。 但不能使用listener/valueChangeListener获取它
我的xhtml代码:
<p:selectOneMenu id="test" value="#{report.location}" style="width:13% !important;">
<p:ajax listener="#{report.locationChange}" />
<f:selectItem itemLabel="All" itemValue="All" />
<f:selectItem itemLabel="INSHOP" itemValue="INSHOP" />
<f:selectItem itemLabel="INSTORAGE" itemValue="INSTORAGE" />
</p:selectOneMenu>
用于侦听器打印位置值的My Java代码:
public void locationChange() {
//location = (String) ((UIOutput) event.getSource()).getValue();
System.out.println("Location :: "+location);
}
它没有打印位置,只是给我空值
但是当我在对话框外尝试同样的事情时,它会显示正确的结果
# 1 楼答案
尝试在p:selectOneMenu中使用valueChangeListener=“#{report.locationChange}”而不是p:ajax
注意:此代码应包含在a<;h:表格></h:表格>