我使用 rich:autocomplete
进行用户搜索。
搜索结果包含用户的所有详细信息,如姓名、地址、年龄和照片。
这是我的代码:
<rich:autocomplete mode="client" showButton="true"
layout="table" autocompleteMethod="#{patientSearch.autocomplete}"
fetchValue="#{patient.patientId}" id="txtPatientSearch" var="patient">
<rich:column>
<h:graphicImage value="/resources/images/default.png" />
</rich:column>
<rich:column>
<h:outputText value="#{patient.fname}" />
</rich:column>
<rich:column>
<h:outputText value="#{patient.lname}" />
</rich:column>
<rich:column>
<h:outputText value="#{patient.gender}" />
</rich:column>
<rich:column>
<h:outputText value="#{patient.mrn}" />
</rich:column>
</rich:autocomplete>
以及来自 bean 的自动完成方法:
public List<SearchPatient> autocomplete(String search) {
ArrayList<SearchPatient> result = new ArrayList<SearchPatient>();
Iterator<SearchPatient> iterator
= patientDAO.searchPatientByAll(search, 1, this.sessionToken).iterator();
while (iterator.hasNext()) {
SearchPatient elem = ((SearchPatient) iterator.next());
result.add(elem);
}
return result;
}
但是当我部署我的应用程序时,它给出了异常:
javax.el.PropertyNotFoundException: Property 'autocomplete' not found on type xtremum.health.web.bean.PatientSearchBean
这个bean包含自动完成方法。如何使用表结构的自动完成功能?
最佳答案
您好,我的问题已解决,我对代码进行了更改,更改是
- 将模式从客户端更改为 ajax,
- autocompleteMethod 和 autocompleteList 都添加到标签中
这是 XHTML
<rich:autocomplete mode="ajax" showButton="true"
layout="table" autocompleteMethod="#{patientSearch.searchPatientByAll}"
autocompleteList="#{patientSearch.searchPatient}"
fetchValue="#{patient.patientId}" id="txtPatientSearch" var="patient">
<rich:column>
<h:graphicImage value="/resources/images/default.png" />
</rich:column>
<rich:column>
<h:outputText value="#{patient.fname}" />
</rich:column>
<rich:column>
<h:outputText value="#{patient.lname}" />
</rich:column>
<rich:column>
<h:outputText value="#{patient.gender}" />
</rich:column>
<rich:column>
<h:outputText value="#{patient.mrn}" />
</rich:column>
</rich:autocomplete>
bean 方法看起来像
private @Getter @Setter List<SearchPatient> searchPatient;
public List<SearchPatient> searchPatientByAll(String search) {
this.searchPatient=patientDAO.searchPatientByAll(search, 1, this.sessionToken);
return this.searchPatient;
}
关于java - 如何在表格布局中使用 richfaces 的自动完成功能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5335081/