从<p:autocomplete>获取值ID

时间:2017-10-25 09:36:54

标签: java jsf primefaces xhtml

<p:autoComplete>

获取价值ID

这是我的xhtml

<p:autoComplete 
dropdown="true" 
value="#{kabupatenBacking.selectedServiceLocation}" 
completeMethod="#{kabupatenBacking.autoComplete}" 
var="svl" 
itemLabel="#{svl.serviceLocationName}"
itemValue="#{svl.serviceLocationID}">
</p:autoComplete>

这是我的豆子

private KabupatenEntity selectedServiceLocation;

public List<KabupatenEntity> autoComplete(String query)
{
    listServiceLocation = kabupatenRules.getServiceLocationByStatus();
    List<KabupatenEntity> queried = new ArrayList<KabupatenEntity>();
    String output = query.substring(0,1).toUpperCase() + query.substring(1);
    for(KabupatenEntity kabupaten : listServiceLocation)
    {
        if(kabupaten.getServiceLocationName().contains(output))
        {
            queried.add(kabupaten);
        }
    }
    return queried;
}

问题是我把组件itemValue.autocomplete不起作用 enter image description here

但是当我从<p:autoComplete>中移除ItemValue时就可以了 enter image description here

但我需要价值,如何才能获得价值?

谢谢

0 个答案:

没有答案