Bug? — Null values in widgets are... well, 4 byte length strings :)

Uhm…

TextField blah = new TextField("Superblah");
blah.setValue(null); // normally it supposed to be empty

Now, why it shows me a value of length of 4 (four) bytes of
java.lang.String
type, where characters are ‘n’, ‘u’, ‘l’ and ‘l’, while I asked to shut up and stay empty?

This yields to TextField, text area (well, of course) and rich text. Well, maybe elsewhere, but just noticed this one.

If you set null value for TextField, it will show “null” as text. You can control this by setNullRepresentation(), which is by default “null”: You could use setNullRepresentation(“”) if you want to have it empty when its null. However, notice that if the user inputs the null representation (“null” or “”), the value will be null. In some cases this may be desirable, in some cases not.

The TextField value can not be “really null”; if you set setNullRepresentation(null), setting setValue(null) throws exception. The default textual null representation is there foremost to notify the developer that the value is null. I think only the “” setting may be really useful.