I tried to create a float field in Vaadin from String field (I dont know any other method ;)
I have a validation which should allow me that a String field will be just a float field. I found only a solution for an integer? How to asure that my user can type only float number?
@Override
public void setConfiguration(EditorConfiguration editorConfiguration) {
Validator<String> validator = ((FloatFieldConfiguration) editorConfiguration).getValidator();
if (validator != null) {
binder.forField(this).withValidator(validator)
.withConverter(new StringToFloatConverter("Must enter a number"))
.bind(s -> getValue(), (b, v) -> setValue(v));
}
}