Source Viewer : WEB-INF/classes/org/apache/click/examples/page/ajax/AutoCompletePage.java
package org.apache.click.examples.page.ajax;
import java.util.List;
import javax.annotation.Resource;
import org.apache.click.control.FieldSet;
import org.apache.click.control.Form;
import org.apache.click.examples.page.BorderPage;
import org.apache.click.examples.service.PostCodeService;
import org.apache.click.extras.control.AutoCompleteTextField;
import org.springframework.stereotype.Component;
/**
* Provides AJAX AutoCompleteTextField example page.
*/
@Component
public class AutoCompletePage extends BorderPage {
private static final long serialVersionUID = 1L;
private Form form = new Form("form");
@Resource(name="postCodeService")
private PostCodeService postCodeService;
// ------------------------------------------------------------ Constructor
public AutoCompletePage() {
addControl(form);
FieldSet fieldSet = new FieldSet("Enter a Suburb Location");
fieldSet.setStyle("background-color", "");
form.add(fieldSet);
AutoCompleteTextField locationField = new AutoCompleteTextField("location") {
private static final long serialVersionUID = 1L;
public List getAutoCompleteList(String criteria) {
return postCodeService.getPostCodeLocations(criteria);
}
};
locationField.setSize(40);
fieldSet.add(locationField);
}
}