Has anyone implemented auto suggest with ComboBox such that everytime the user types on ComboBoxItem, a request is sent to the server ( REST styled)
If I use RESTDataSource, I can only use a static DataURL. But I want to use a custom url everytime for e.g
when the user types a
the url is
/restlet/peopleFinder/a
when the user types aaa
the url is
/restlet/peopleFinder/aaa
How can I achive this?
Right now I am trying to override the addChangedHandler method in the following way but the auto suggest part stops working after I replace the datasource.
comBoxItem.addChangedHandler(new ChangedHandler() {
public void onChanged(ChangedEvent event) {
if(event.getValue()!=null && event.getValue().toString().trim().length()>=3){
final Client client = new Client(Protocol.HTTP);
System.out.println("requestSuggestions "+ event.getValue());
client.get("http://localhost:8080/CaseManager/restlet/peoplefinder/"+event.getValue(), new org.restlet.gwt.Callback(){
@Override
public void onEvent(org.restlet.gwt.data.Request requestR, org.restlet.gwt.data.Response responseR) {
try{
DataSource ds = new DataSource();
ds.setClientOnly(true);
Document XMLdoc= com.google.gwt.xml.client.XMLParser.parse(responseR.getEntity().getText()) ;
System.out.println("Result lenght is "+XMLdoc.getElementsByTagName("record").getLength());
for(int i =0; i<XMLdoc.getElementsByTagName("record").getLength();i++){
NodeList nl=
XMLdoc.getElementsByTagName("record").item(i).getChildNodes();
ListGridRecord record = new ListGridRecord();
record.setAttribute("displayName",nl.item(0));
record.setAttribute("employeeNumber", nl.item(1));
record.setAttribute("orgUnitDescription",nl.item(2));
ds.addData(record);
peopleSearch.setOptionDataSource(ds);
peopleSearch.setShowOptionsFromDataSource(true);
}
catch(Exception e){
e.printStackTrace();
}
}
});
}