List of usage examples for org.apache.wicket.markup.html.form FormComponent getRawInput
public final String getRawInput()
From source file:com.chitek.wicket.listeditor.UniqueListItemValidator.java
License:Apache License
/** * Validator for items in {@link ListEditor}. Validates the input to be unique among all * entrys in the list. /*from ww w . j ava 2 s . c o m*/ */ @SuppressWarnings("rawtypes") @Override public void validate(IValidatable<T> validatable) { ListEditor<?> editor = parent.findParent(ListEditor.class); String id = parent.getId(); int count = 0; List<FormComponent> fields = editor.getComponentsById(id, FormComponent.class); String parentValue = getValue(validatable); if (filter != null && caseSensitive && !filter.contains(parentValue)) return; if (filter != null && !caseSensitive && !filter.contains(parentValue.toLowerCase())) return; if (filter != null && !caseSensitive && !filter.contains(parentValue.toUpperCase())) return; for (FormComponent field : fields) { String value = field.getRawInput() != null ? field.getRawInput().toString() : null; if (value != null && (caseSensitive ? value.equals(parentValue) : value.equalsIgnoreCase(parentValue))) { count++; } } if (count > 1) { ValidationError error = new ValidationError(); error.addKey(messageKey); validatable.error(error); } }