我对 p:autocomplete 有疑问:当验证在任何其他字段上失败时,我会错过自动完成的输入。我能做些什么来避免这种情况?
我正在使用带有 mojarra 2.1.18 的素面 3.5。这是代码:
<h:outputLabel for="employmentTitle" value="Dienstbezeichnung:" />
<p:autoComplete id="employmentTitle" minQueryLength="3" maxResults="20" value="#{contactManagedBean.contactPerson.employmentTitle}" label="Dienstbezeichnung" var="e" itemValue="#{e}"
itemLabel="#{e.value}" effect="fade" completeMethod="#{contactManagedBean.completeEmploymentTitles}" converter="#{keyValueTableConverter}">
<f:validator validatorId="contactPersonTypeFacesValidator" />
<f:attribute name="contactPerson" value="#{contactManagedBean.contactPerson}" />
<f:attribute name="personTypeComponent" value="#{personTypeComponent}" />
</p:autoComplete>
编辑:
对不起我的错。我的 KeyValueTableConverter 错过了对服务 bean 的调用,如下所示:
/**
*
* make an object from web request param
*/
@Override
public Object getAsObject(FacesContext context, UIComponent component, String param) {
KeyValueTable k = null;
try {
k = serviceBean.getValuesById(Long.parseLong(param));
} catch (Exception e) {
logger.error("Error while making an object from web request param: " + param + " keyvaluetable: " + k, e);
}
return k;
}