java - 如何在表格布局中使用 richfaces 的自动完成功能?

标签 java eclipse jsf jboss richfaces

我使用 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包含自动完成方法。如何使用表结构的自动完成功能?

最佳答案

您好,我的问题已解决,我对代码进行了更改,更改是

  1. 将模式从客户端更改为 ajax,
  2. 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/

相关文章:

java - Eclipse 没有构建 aidl 文件

Eclipse Tomcat 错误 404

java - 如何将 javascript 文件捆绑到 Java 应用程序中?

java - spring加载xml文件

java - 为什么 Eclipse 不显示 "Run"或 "Run configuration"?

java - 有人使用 Eclipse 成功构建了 Bruce Eckels 的 'Thinking in java' 第四版吗?

javascript - 单击按钮后在 css 弹出窗口中填充值

jsf - PrimeFaces 对话框延迟加载(动态 ="true")不起作用?

java - 接口(interface)可以禁止具有特定数据类型的对象吗?

Java:无法更改另一个 java 文件中的 JFrame 组件的内容