Why default value of an unchecked CheckBox is null?

According to
the docs
, “CheckBox is a two-state selection component that can be either checked or unchecked” { … } “Clicking on a check box will change its state. The state is a Boolean property that you can set with the setValue() method and obtain with the getValue() method of the Property interface”.

However, if you put a CheckBox without explicitly setting a value (that is, it will be displayed as an unchecked checkbox) with
and retrieve its value with a
, you realize that is value is

I understand that the Java
class can be
, but what sounds unconsistent to me is that the possible value representation of the “visual representation” of an unchecked checkbox may be actually one of two possible values: false or null, thus effectively converting the CheckBox control in a


Shouldn’t this be clearly stated in the manual? It took me some time to figure out what was happening. I think it should be noted that if no explicit value is set during CheckBox initialization,
is the default until it gets checked / unchecked…

This is prone to errors as actually an unchecked checkbox may mean eiter that the value is
or that we don’t know what the value is…

Also, unintentioned or not, the Vaadin sampler example shows a checkbox checked by default, so there’s no way to realize this behaviour from there… Shouldn’t be better to show an unchecked box by default, with a
showing the current value (even without having clicked it for the 1st time), to clearly demonstrate the values it may hold?


that sounds like a legit bug to me, do you care to
file a bug report



Thanks a lot for your reply, Olli.

Sorry Olli but I just discovered what is the source of this behaviour: I had my CheckBox created via FieldGroup.buildAndBind(), bind to a new, fresh, empty item added via .addItem(), in order to create record and store it in the database.

Does this still applies for a bug?

I think it might, although I’m not the final arbiter. I can at least think of a real life use case where I’m ok with the default values of a (short) form.