I have a TextField that is bound to a Double. When using a new model object that Double will be null. To get it working I had to use the withNullRepresentation(0.0) but that puts a zero in the Text Field. How do I get the text field to be empty when I have a null Double? I really don’t want the user to have to remove the zero before entering a value.
binder.forField(length).withConverter(new StringToDoubleConverter(0.0,"Please enter a number")).withNullRepresentation(0.0).bind("length");
Don’t know if withNullRepresentation(“”) will work. If not, you can create your own copy of StringToDoubleConverter (or override) and have it return “” when the value is null.
Don’t know if withNullRepresentation(“”) will work. If not, you can create your own copy of StringToDoubleConverter (or override) and have it return “” when the value is null.
I have a TextField that is bound to a Double. When using a new model object that Double will be null. To get it working I had to use the withNullRepresentation(0.0) but that puts a zero in the Text Field. How do I get the text field to be empty when I have a null Double? I really don’t want the user to have to remove the zero before entering a value.
binder.forField(length).withConverter(new StringToDoubleConverter(0.0,"Please enter a number")).withNullRepresentation(0.0).bind("length");
This to fully work as it should may require this https://github.com/vaadin/flow/pull/9227, which I think is not yet released, but will be in some upcoming version.
Tatu Lund:
This to fully work as it should may require this https://github.com/vaadin/flow/pull/9227, which I think is not yet released, but will be in some upcoming version.