public void onClick(AjaxRequestTarget target) {
setSearchType(ALL);
setResponsePage(TweetSearchPage.class, getParams(query, selectedIndex, null, loggedInUser));
}
}));
final RadioGroup rg = new RadioGroup("searchTypes", new PropertyModel(this, "selectedIndex"));
final Button buttonRight = new Button("submitbutton") {
@Override
public void onSubmit() {
setResponsePage(TweetSearchPage.class, getParams(query, selectedIndex, userName, loggedInUser));
}
};
final Button bttnLeft = new Button("submitbuttonleft") {
@Override
public void onSubmit() {
buttonRight.onSubmit();
}
};
form = new Form("searchform") {
@Override
public void onSubmit() {
buttonRight.onSubmit();
}
};
form.add(new BookmarkablePageLink("homelink", TweetSearchPage.class));
// buttonRight.add(new EffectBehavior(new BounceEffect()));
form.add(buttonRight);
form.add(bttnLeft);
form.setMarkupId("queryform");
add(form);
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);
if (showSpacer)
form.add(new AttributeAppender("class", new Model("not-logged-in-spacer"), " "));
form.add(rg);