【问题标题】:How to use autocomplete of richfaces with table layout?如何在表格布局中使用 Richfaces 的自动完成功能?
【发布时间】:2011-07-17 03:28:41
【问题描述】:

我使用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:在类型 xtremum.health.web.bean.PatientSearchBean 上找不到属性“自动完成”

这个 bean 包含自动完成方法。表结构如何使用自动补全?

【问题讨论】:

  • 能否贴出相关代码?
  • 请格式化可读的代码
  • 我正确地编写了代码,但它不会正确显示.. 抱歉,我什么都做不了,这不是我的问题..
  • :) 有一些工具,如果你已经正确观察了文本编辑器,请使用它们
  • 但是我只想回答这个问题,我没有足够的时间搜索 abt 编辑器工具

标签: java eclipse jsf jboss richfaces


【解决方案1】:

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

  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;
}

【讨论】:

    猜你喜欢
    • 2016-10-09
    • 2013-10-02
    • 1970-01-01
    • 2022-08-15
    • 2014-04-20
    • 1970-01-01
    • 2015-06-20
    • 2016-06-14
    • 1970-01-01
    相关资源
    最近更新 更多