当我在p:autocomplete中第一次选择值时,它会触发set方法。但是,当我尝试再次选择值时,没有任何反应(根据调试它甚至不会触发setter)
在浏览器网络监视器中,我看到在select
上返回的xml中添加了以下字符串<extension ln="primefaces"type="args">{"validationFailed":true}</extension>
但我没有在那里使用任何验证
primefaces版本是3.3.1
我的面孔代码:
<p:autoComplete value="#{cityManager.kladrCity}"
completeMethod="#{cityManager.searchKladr}" var="p"
itemLabel="#{p.fullName}" itemValue="#{p}"
converter="#{kladrCityConverter}" id="kladrCity"
forceSelection="true">
<p:ajax event="itemSelect"
listener="#{cityManager.handleKladrSelect}" update="name zipCode" immediate="true"/>
</p:autoComplete>
转换器代码:
@Named("kladrCityConverter")
public class KladrCityConverter implements Converter {
@Inject
private KladrService kladrService;
@Override
public Object getAsObject(FacesContext arg0, UIComponent arg1, String key) {
if(key == null || key.trim().equals("")){
return null;
}
KladrCity obj = kladrService.findById(key);
return obj;
}
@Override
public String getAsString(FacesContext arg0, UIComponent arg1, Object obj) {
if(obj == null){
return "";
}
KladrCity kladrCity = (KladrCity) obj;
return kladrCity.getCode();
}
}
答案 0 :(得分:0)
更改
@Named("kladrCityConverter")
到
@FacesConverter("locationConverter")