简体   繁体   中英

How to use autocomplete of richfaces with table layout?

I'm using rich:autocomplete for user search.

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:

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

this bean contains autocomplete method. 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,
  2. autocompleteMethod & autocompleteList both are added in tag

Here is the 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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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