简体   繁体   English

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

[英]How to use autocomplete of richfaces with table layout?

I'm using rich:autocomplete for user search. 我正在使用rich:autocomplete进行用户搜索。

Search result contains all the details of user like name, address, age & photo. 搜索结果包含用户的所有详细信息,例如姓名,地址,年龄和照片。

This is my code: 这是我的代码:

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

and the autocomplete method from the bean: 以及来自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;
}

but when I deploy my app it gives exception: 但是当我部署我的应用程序时,它会给出异常:

javax.el.PropertyNotFoundException: Property 'autocomplete' not found on type xtremum.health.web.bean.PatientSearchBean javax.el.PropertyNotFoundException:在类型xtremum.health.web.bean.PatientSearchBean上找不到属性“ autocomplete”

this bean contains autocomplete method. 该bean包含自动完成方法。 How to use autocomplete for table structure? 如何使用自动完成的表结构?

Hello my problem is solved i make changes in my code and changes are 您好,我的问题已解决,我在代码中进行了更改,更改是

  1. change mode from client to ajax, 从客户端更改为ajax模式,
  2. autocompleteMethod & autocompleteList both are added in tag autocompleteMethod和autocompleteList都添加在标记中

Here is the XHTML 这是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>

the bean method looks like bean方法看起来像

private @Getter @Setter List<SearchPatient> searchPatient;
public List<SearchPatient> searchPatientByAll(String search) {
  this.searchPatient=patientDAO.searchPatientByAll(search, 1, this.sessionToken);
  return this.searchPatient;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM