开发者

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>

an开发者_如何转开发d 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;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜