I am trying to use autocomplete feature of primefaces but when I try to call bean method from my facelet then it shows an error that mybean has not such method
here is my code
Page.xhtml
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:head>
<title>Title</title>
</h:head>
<h:body>
<h:form id="form">
<p:panel header="AutoComplete" toggleable="true" id="panel">
<h:panelGrid columns="2" cellpadding="5">
<h:outputLabel value="Simple :" for="acSimple" />
<p:autoComplete id="acSimple" value="#{myBean.txt1}"
completeMethod="#{myBean.complete}"/>
</h:panelGrid>
</p:panel>
</h:form>
</h:body>
</html>
MyBean.java
import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
@ManagedBean(name="myBean")
@RequestScoped
public class MyBean {
private String txt1;
public List<String> complete(String query) {
List<String> results = new ArrayList<String>();
for (int i = 0; i < 10; i++) {
results.add(query + i);
}
return results;
}
public String getTxt1() {
return txt1;
}
public void setTxt1(String txt1) {
this.txt1 = txt1;
}
}
So when i run this code, it is showing an error that myBean has no property 'complete'.I am using eclipse and latest version of primefaces.
Am i doing something wrong here?
please help
Thx