Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Oct 22, 2015
2 parents 120879a + ba00d1a commit a4cf25e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
Expand Up @@ -40,6 +40,8 @@ public AutoCompleteTextPanel(String id, IModel<T> model, Class clazz) {

AutoCompleteSettings autoCompleteSettings = new AutoCompleteSettings();
autoCompleteSettings.setShowListOnEmptyInput(true);
autoCompleteSettings.setShowListOnFocusGain(true);
autoCompleteSettings.setShowCompleteListOnFocusGain(true);
final AutoCompleteTextField<T> input = new AutoCompleteTextField<T>(ID_INPUT, model, autoCompleteSettings) {

@Override
Expand Down
Expand Up @@ -31,7 +31,9 @@
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
import org.apache.wicket.ajax.form.OnChangeAjaxBehavior;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteTextField;
import org.apache.wicket.extensions.yui.calendar.DateTimeField;
import org.apache.wicket.feedback.ComponentFeedbackMessageFilter;
import org.apache.wicket.markup.html.WebMarkupContainer;
Expand Down Expand Up @@ -554,12 +556,45 @@ public DeltaDto getObject() {

panel = new AutoCompleteTextPanel<String>(id, new LookupPropertyModel<String>(model, baseExpression, lookupTable.asObjectable()), type) {


@Override
public Iterator<String> getIterator(String input) {
return prepareAutoCompleteList(input, lookupTable).iterator();
}
};

final AutoCompleteTextField component = (AutoCompleteTextField)panel.get(0);
component.add(new OnChangeAjaxBehavior(){
@Override
protected void onUpdate(AjaxRequestTarget target) {
ValueWrapper valueWrapper = model.getObject();
valueWrapper.getItem();
Iterator<String> lookupTableValuesIterator = prepareAutoCompleteList("", lookupTable).iterator();

String value = component.getInput();
boolean isValueExist = false;
if (value != null) {
if (value.trim().equals("")){
isValueExist = true;
} else {
while (lookupTableValuesIterator.hasNext()) {
String lookupTableValue = lookupTableValuesIterator.next();
if (value.trim().equals(lookupTableValue)) {
isValueExist = true;
break;
}
}
}
}
if (isValueExist){
component.setModelValue(new String[]{value});
target.add(PrismValuePanel.this.get(ID_FEEDBACK));
} else {
component.error("Entered value doesn't match any of available values and will not be saved.");
target.add(PrismValuePanel.this.get(ID_FEEDBACK));
}
}
});
} else {
panel = new TextPanel<>(id, new PropertyModel<String>(model, baseExpression), type);
}
Expand Down

0 comments on commit a4cf25e

Please sign in to comment.