use of com.evolveum.midpoint.gui.api.component.autocomplete.LookupTableConverter in project midpoint by Evolveum.
the class TextPopupPanel method initTextField.
private TextField initTextField() {
if (lookup == null) {
return new TextField(ID_TEXT_INPUT, new PropertyModel(getModel(), SearchValue.F_VALUE));
}
// TODO: displayName
// LookupPropertyModel<String> lookupPropertyModel = new LookupPropertyModel<String>(getModel(), SearchValue.F_VALUE, lookup.asObjectable()) {
//
// private static final long serialVersionUID = 1L;
//
// @Override
// public boolean isSupportsDisplayName() {
// return true;
// }
// };
AutoCompleteSettings settings = new AutoCompleteSettings();
settings.setShowListOnEmptyInput(true);
AutoCompleteTextField<String> textField = new AutoCompleteTextField<String>(ID_TEXT_INPUT, new PropertyModel<>(getModel(), SearchValue.F_VALUE), settings) {
private static final long serialVersionUID = 1L;
@Override
protected Iterator<String> getChoices(String input) {
return prepareAutoCompleteList(input).iterator();
}
@Override
public <C> IConverter<C> getConverter(Class<C> type) {
IConverter<C> converter = super.getConverter(type);
if (lookup == null) {
return converter;
}
return new LookupTableConverter(converter, lookup.asObjectable(), this, false) {
@Override
public Object convertToObject(String value, Locale locale) throws ConversionException {
PropertyModel<Object> label = new PropertyModel<>(TextPopupPanel.this.getModelObject(), SearchValue.F_LABEL);
label.setObject(value);
return super.convertToObject(value, locale);
}
};
}
};
return textField;
}
Aggregations