本文整理汇总了Java中org.apache.wicket.extensions.ajax.markup.html.autocomplete.AbstractAutoCompleteRenderer类的典型用法代码示例。如果您正苦于以下问题:Java AbstractAutoCompleteRenderer类的具体用法?Java AbstractAutoCompleteRenderer怎么用?Java AbstractAutoCompleteRenderer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AbstractAutoCompleteRenderer类属于org.apache.wicket.extensions.ajax.markup.html.autocomplete包,在下文中一共展示了AbstractAutoCompleteRenderer类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: AssociationFieldAutoCompleteTextField
import org.apache.wicket.extensions.ajax.markup.html.autocomplete.AbstractAutoCompleteRenderer; //导入依赖的package包/类
public AssociationFieldAutoCompleteTextField(String id, IModel<Topic> model, final RoleFieldModel valueFieldModel) {
super(id);
AutoCompleteSettings opts = new AutoCompleteSettings();
opts.setCssClassName("ontopoly-autocompleter");
opts.setAdjustInputWidth(false);
opts.setPreselect(true);
this.textField = new AutoCompleteTextField<Topic>("autoComplete", model, Topic.class, new AbstractAutoCompleteRenderer<Topic>() {
@Override
protected String getTextValue(Topic o) {
return TOPIC_CONVERTER.convertToString(o);
}
@Override
protected void renderChoice(Topic o, Response response, String criteria) {
response.write(o.getName());
}}, opts) {
@Override
public IConverter getConverter(Class<?> type) {
if (Topic.class.equals(type)) {
return new TopicConverter();
} else {
return super.getConverter(type);
}
}
@Override
protected Iterator<Topic> getChoices(String input) {
List<Topic> result = new ArrayList<Topic>(valueFieldModel.getRoleField().searchAllowedPlayers(input));
filterPlayers(result);
Collections.sort(result, TopicComparator.INSTANCE);
return result.iterator();
}
@Override
protected void onModelChanged() {
super.onModelChanged();
Topic topic = getModelObject();
if (topic != null) {
AssociationFieldAutoCompleteTextField.this.onTopicSelected(topic);
}
}
};
add(textField);
}