TextField null representation and setting value programmatically

Hi all,

Using Vaadin v7.5.9, I have a textfield declared as follows:

TextField tf = new TextField();
tf.setNullRepresentation("");
tf.setNullSettingAllowed(true);
tf.setImmediate(true);
tf.addValueChangeListener( .. )

Now, if I programmatically set its value to the empty string…

tf.setValue(""); … and then retrieve its value in the ValueChangeListener…

String value = tf.getValue(); … the resulting
value
should be null, right? Or have i missed something?

Anyways,
value
turns out to be the empty string.

Is this a bug?

No - from javadoc of [i]
setNullRepresentation:

Textual representation for null strings.

[/i]Nothing about converting a
null representaion
to
null value.

Javadoc of
setNullSettingAllowed
:

[code]
Sets the null conversion mode.

If this property is true, writing null-representation string to text field always sets the field value to real null.
[/code]Sou you need to call:

setNullSettingAllowed(true); to get
null
for empty string.