AutoCompleteSettings config = new AutoCompleteSettings().setUseHideShowCoveredIEFix(false);
config.setThrottleDelay(200);
// connect the form's textfield with the java property
queryTF = new MyAutoCompleteTextField("textField",
new PropertyModel(this, "query"), config) {
@Override
protected Iterator getChoices(String input) {
return SearchBox.this.getQueryChoices(input).iterator();
}
@Override
protected void onSelectionChange(AjaxRequestTarget target, String newValue) {
SearchBox.this.onSelectionChange(target, newValue);
}
};
queryTF.add(new DefaultFocusBehaviour());
// autosubmit when user selects choice -> problem: the user text will be submitted although it should be cleared before submit
// queryTF.add(new AjaxFormSubmitBehavior(form, "onchange") {
//
// @Override
// protected void onSubmit(AjaxRequestTarget target) {
// }
//
// @Override
// protected void onError(AjaxRequestTarget target) {
// }
// });
queryTF.setMarkupId("querybox");
form.add(queryTF);
MyAutoCompleteTextField userTF = new MyAutoCompleteTextField("userTextField",
new PropertyModel(this, "userName"), config) {
@Override
protected Iterator getChoices(String input) {
return SearchBox.this.getUserChoices(input).iterator();
}
@Override
protected void onSelectionChange(AjaxRequestTarget target, String newValue) {
//"Not supported yet."
}
};
userTF.setMarkupId("userbox");
rg.add(new Radio("0", new Model(0)).setMarkupId("sbnone"));
rg.add(new Radio("1", new Model(1)).setMarkupId("sbfriends"));
rg.add(new Radio("2", new Model(2)).setMarkupId("sbuser"));
rg.add(userTF);