Vaadin8 binding, null representation for Integer

Hi all,

would it be possible to set null representation of the text filed with StringToIntegerConverter to be “” (blank)? I dont like the blank Integer fields having 0, but if I want to use StringToIntegerConverter, null representation has to be Integer (0).

binder.forField(fldAge)
	.withConverter(new StringToIntegerConverter("Wrong!"))
	.withNullRepresentation(0) //how to make it blank but still bind to Integer property? 
	.bind(Person::getAge, Person::setAge);

I guess I need to write my own converter, right? Any hints please?

Thanks!

It is actually rather easy:

binder.forField(fldAge)
	.withConverter(
		fieldValue -> Objects.equals(fieldValue,"")  ? null : Integer.parseInt(fieldValue),
		modelValue -> Objects.isNull(modelValue)? "" :  modelValue.toString())
	.bind(Person::getAge, Person::setAge);