iam使用primefaces自动完成,它工作正常,但如果我设置默认值它给我一个错误。 这是我的Xhtml代码:
<p:autoComplete id="parametername" required="true"
requiredMessage="Parameter Name can't be blank"
maxResults="5"
value="#{manageAppParaValuesTO.appParameterValuesBean.parameterName}"
tabindex="1" forceSelection="true"
styleClass="select-area-150 CommoninputText input_text_style1" cache="enabled"
dropdown="true"
completeMethod="#{manageAppParaValuesTO.completeDropDownParameter}"
disabled="#{manageAppParaValuesTO.deleteFlag or manageAppParaValuesTO.viewFlag or manageAppParaValuesTO.editFlag}"
var="field" itemValue="#{field.parameterName}"
itemLabel="#{field.parameterName}">
这是java代码:
public List<ApplicationParameterValuesEntityTO> completeDropDownParameter(
String like) {
System.out.println("-----------------> completeParameter ");
newAppParameterNameDropDown = new ArrayList<ApplicationParameterValuesEntityTO>();
for(ApplicationParameterValuesEntityTO appValueEntity : appParameterNameDropDown){
System.out.println(" Like "+like+"-------> appValueEntity.getParameterName "+appValueEntity.getParameterName());
if(appValueEntity.getParameterName().toUpperCase().matches(like+".*") || appValueEntity.getParameterName().toLowerCase() .matches(like+".*")){
System.out.println("-------->"+appValueEntity.getParameterName());
newAppParameterNameDropDown.add(appValueEntity);
}
}
return newAppParameterNameDropDown;
}
如果manageAppParaValuesTO.appParameterValuesBean.parameterName已有值,则会遇到以下错误:
javax.el.PropertyNotFoundException: itemLabel="#{field.parameterName}": Property 'parameterName' not found on type java.lang.String